Transaction and ACID properties
October 9, 2012 Leave a comment
A set of statements executed on a resource or resources applied with ACID properties is known as Transaction.
Note: Here database is one resource but resource need not be only database
ACID Properties:
- Atomicity
- Consistency
- Isolation
- Durability
Atomicity:
This property describes that the set of statements involved in the transaction has to work as a single unit (i.e, automic). This is the minimum requirement that has to be met for a transaction
Consistency:
If the data used in the transaction is consistent before starting the transaction, then it has to be left in a consistent state even after the transaction.
Note: What is consistent data: data applied with some rules.
Example:
accountNo | accountBal
101 | 6000
Here lets define a rule that says if: accountBal>5000; then it is said to be in consistent state.
so before transaction it is 6000 and after transaction lets say it has become 8000, then it is left in consistent state. If it falls below 5000, ie, lets say 4000, then it is said to be inconsistent state in which case we will rollback the transaction
And if the data used in the transaction is already in inconsistent state then we cannot guarantee the consistent data after the transaction.
Isolation:
It is an ability to isolate the data used in one transaction from the other transaction.
Durability:
Once the transaction starts to save, it should definitely save all the statements within the transaction at any cost else rollback all the statements and throw exception.
Recent Comments