ACID properties in DBMS

In relational databases, transaction is a single logical unit of work. Transactions access or manipulate data using read and write operations. In order to work database operations in consistent way, certain properties are followed, and these are called ACID properties.

 

A – Atomicity (All operations either fail or succeed in single transaction)

C – Consistency (Refers to correctness of database after a transaction)

I – Isolation (Concurrent transactions execute independently without interfering)

D – Durability (If transaction is committed, data is stored in non-volatile memory)

 

Atomicity
Consider the following transaction T consisting of T1 and T2: Transfer of 100 from account A to account B.

Before A=1000 B=500
T1 T2
Read (A)

A=A-100

Write (A)

Read (B)

B=B+100

Write (B)

After A=900 B=400

 

If the transaction fails after completion of T1 but before completion of T2, then amount has been deducted from A but not added to B. This results in an inconsistent database state. Therefore, the transaction must be executed entirety in order to ensure correctness of database state.

Consistency
This means that integrity constraints, triggers, rules etc. must be maintained so that the database is consistent before and after the transaction. It refers to correctness of a database.

Isolation
Isolation ensures that multiple transactions can occur concurrently without leading to inconsistency of database state. Transactions occur independently without interference. Changes occurring in a particular transaction will not be visible to any other transaction until that change in that transaction is written to memory or has been committed. This property ensures that the execution of transactions concurrently will result in a state that is equivalent to a state achieved these were executed serially in some order.

Durability
Durability ensures that once the transaction has completed execution, the updates and modifications to the database are stored in and written to disk and they persist even if system failure occurs. These updates now become permanent and are stored in a non-volatile memory. The effects of the transaction, thus, are never lost.

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.