Every transaction in DBMS has four distinct properties. These properties are for the maintenance of consistency in the database before, during, and after the execution of the transaction.
Properties of the transaction
- Consistency of database occurs through the maintenance of the integrity constraints.
- The complete execution of the transaction shall either render the database with its former state or new state.
- This property implies that the transactions shall witness a consistent instance of the database and transform it from a consistent state to the next.
For instance, there has to be the maintenance of the total sum before and post-transaction.
- Atomicity implies that every operation of the transaction will occur at once and if not, then abortion of the entire transaction shall take place.
- According to this property, there is no partial occurrence of the transaction. Every transaction is a single unit that will either be completed or aborted in entirety.
Abort: Abortion of a transaction makes the changes made invisible
Commit: Upon the successful commit of a transaction, all changes become visible.
For instance, let there be a transaction T that consists of transaction T1 and transaction T2. Let A have Rs 200 and B have Rs 300. Transferring Rs 100 from A to B via bank accounts.
After the transaction is over, A has Rs 100 and B has Rs 400. If there is a failure in the transaction T after T1 gets completed, but before T2 starts, then the sum which gets deducted from A will not be added to the account of B. Thus an inconsistency arises which can only be resolved by the completion of the entire transaction or atomicity.
- Durability implies that the changes made by the transaction to the database are permanent.
- It is the responsibility of the recovery subsystem to maintain durability.
- Isolation property means that the data of one transaction cannot be used in the next until the first one is complete. This property means that if T1 is being executed with data item X, then X cannot be accessed by transaction T2 until T1 is over.
- The subsystem of concurrency control holds the responsibility of maintaining isolation of transaction.