Properties of transactions
- There are properties that all transactions should follow and possess.
- The four basic are in combination termed as ACID properties.
- ACID properties and its concepts of a transaction are put forwarded by Haerder and Reuter in the year 1983.
- It is commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity.
- The ACID has a full form and is as follows:
- A - Atomicity
- C - Consistency
- I - Isolation
- D - Durability
- Atomicity:
- The 'all or nothing' property.
- A transaction is an indivisible entity that is either performed in its entirety or will not get performed at all.
- This is the responsibility or duty of the recovery subsystem of the DBMS to ensure atomicity.
- Example:
- Suppose Account A has a balance of 400 Rs. & B has 700 Rs.
- Account A is transferring 100 Rs. to Account B.
- This is a transaction that has two operations a) Debiting 100 Rs. from A’s balance b) Creating 100 Rs. to B’s balance.
- Let’s say the first operation passed successfully while the second failed.
- So, in this case, A’s balance would be 300 Rs. while B would be having 700 Rs. instead of 800 Rs.
- This is unacceptable in a banking system.
- Either the transaction should fail without executing any of the operations or it should process both the operations.
- The Atomicity property ensures that.
- Consistency:
- A transaction must alter the database from one steady-state to another steady state.
- This is the responsibility of both the DBMS and the application developers to make certain consistency.
- The DBMS can ensure consistency by putting into effect all the constraints that have been mainly on the database schema such as integrity and enterprise constraints.
- Example:
- Account A is having a balance of 400 Rs. and it is transferring 100 Rs. to account B & C both.
- So we have two transactions here.
- Let’s say these transactions run concurrently and both the transactions read 400 Rs. balance.
- In that case, the final balance of A would be 300 Rs. instead of 200 Rs.
- This is wrong.
- If the transaction were to run in isolation then the second transaction would have read the correct balance 300 Rs. (before debiting 100 Rs.)
- Once the first transaction went successful.
- Isolation:
- Transactions that are executing independently of one another is the primary concept followed by isolation.
- In other words, the frictional effects of incomplete transactions should not be visible or come into notice to other transactions going on simultaneously.
- It is the responsibility of the concurrency control sub-system to ensure adapting the isolation.
- Durability:
- The effects of an accomplished transaction are permanently recorded in the database and must not get lost or vanished due to subsequent failure.
- So this becomes the responsibility of the recovery sub-system to ensure durability.
Tags:
DBMS