ACID Properties

ACID properties guarantee a reliable, error free and consistent database transaction.

A transaction is a very small unit of a program and it may contain several low level tasks. A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity.

  • Atomicity − This property states that a transaction must be treated as an atomic unit, that is, either all of its operations are executed or none.

  • Consistency − The database must remain in a consistent state after the execution of the transaction.

  • Isolation − In a database system where multiple transactions are being executed simultaneously, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system.

  • Durability − After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures. That is, after the successful completion of the transaction, the system must store the changes permanently in the hard disk.

Example:
Let us assume that a transaction T1 transfers 5000 from, say account A to account B. Also assume that the initial balance of A is 10000 and B is 10000. Transaction T1 shown below depicts the actual implementation of transfer of money from one account to the other;

Transaction States
Atomicity ensures that either T1 can enter into the new consistent state S2 after successful completion of transaction or T1 can remain in the old consistent state S1 without affecting A and B. If the transaction fails after Write(A) and before Write(B), the system should ensure that its updates are not reflected in the database, else an inconsistency will result.
Consistency ensures that the changes made are legal. That is, either S1 or S2, both should be valid states. It can be evaluated in many ways. For example, for our transaction T1, the sum of A and B, before and after the transaction will be same.
At S1 (Before transaction), A + B = 10000 + 10000 = 20000
At S2 (After transaction), A + B = 5000 + 15000 = 20000
Isolation property ensures the serial execution of transaction and leads to consistent databases. Assume that there is one more transaction T2 executed simultaneously along with T1 as given in Figure; also assume that the initial balance of account C is 5000.

T1 transfers 5000 from account A to B, and T2 transfers 2000 from account A to C. If both transactions read A at the same time, then the Write which happened later would decide the new value of A and hence inconsistent. Therefore, these two transactions should be executed in isolated manner.
Durability ensures that at the end of every successful transaction the data must be written permanently into the hard disk. That is, at the end the table should have new consistent values of A, B, and C in the hard disk.
Implementation of Atomicity and Implementation of Atomicity and Durability
It can be implemented using “shadow-database”scheme.

  • db_Pointer always points to consistent copy of the database.
  • All updates are done on the shadow copy of the database and once the transaction partial commit , db_Pointer points to the updated shadow copy and pages are flushed to the disk.
  • In case of failure, old copy pointed by db_Pointer is used and shadow copy can be deleted.

Leave a Reply

avatar
  Subscribe  
Notify of