DBMS Transaction
-
A transaction is a series of action.
-
It is performed by a single user to perform some operations.
-
It has two important operations:
-
Commit : To save the work done permanently.
- Rollback : To undo the work done.
Properties of Transaction:
- Atomicity : It guarantees that the transaction completes in an all-or-nothing manner.
- Consistency : It ensures the change to data written to the database must be valid and follow predefined rules.
- Isolation : It determines how transaction integrity is visible to other transactions.
- Durability: It makes sure that transactions that have been committed will be stored in the database permanently.
State of transaction:
- Active: Transaction is being executed.
- Partially Committed: Transaction executes its final operation but data is still not saved on database.
- Committed: Execution completed successfully and changes made in the database.
- Failed: If any of the checks made by the database recovery system fails, then the transaction is said to be in the failed state.
- Aborted:
- If any of the checks fail and the transaction has reached a failed state then the database recovery system will make sure that the database is in its previous consistent state. If not then it will abort or roll back the transaction to bring the database into a consistent state.
- If the transaction fails in the middle of the transaction then before executing the transaction, all the executed transactions are rolled back to its consistent state.