ACID Properties
In database systems, a transaction is a logical unit of work that consists of one or more operations performed on the database. To maintain data consistency and integrity, especially in multi-user environments, every transaction must satisfy four essential properties—ACID: Atomicity, Consistency, Isolation, and Durability.
These ACID properties are the foundation of reliable database transactions and are enforced by the DBMS (Database Management System).
1. Atomicity
Atomicity ensures that a transaction is treated as a single, indivisible unit. Either all operations of the transaction are successfully completed, or none of them are. If any part of the transaction fails, the entire transaction is rolled back, and the database is returned to its previous state.
Â
Example:
Â
If you transfer money from Account A to Account B, the transaction involves two steps:
- Deduct amount from Account A
- Add amount to Account B
Â
If the second step fails, atomicity ensures that the amount deducted from Account A is also rolled back.
2. Consistency
Consistency guarantees that a transaction takes the database from one valid state to another valid state, maintaining all defined rules, such as constraints, cascades, and data formats.
Â
Example:
If there’s a rule that account balances cannot be negative, and a transaction violates this rule, then it is not considered consistent and will be rejected.
The database should never be left in an invalid or corrupt state after a transaction.
3. Isolation
Isolation ensures that concurrent transactions do not interfere with each other. Each transaction should execute as if it is the only transaction running, even when multiple transactions are processed simultaneously.
Â
This is especially important in multi-user environments to prevent issues like:
- Dirty Reads
- Non-repeatable Reads
- Phantom Reads
Â
The DBMS uses isolation levels and locking mechanisms to enforce this property.
4. Durability
Durability ensures that once a transaction is committed, its changes to the database are permanent, even in the case of a system crash, power failure, or error.
Â
The DBMS typically uses logs, backups, and write-ahead techniques to ensure that the committed changes can always be recovered.
Â
Example:
If you book a train ticket online and the transaction is confirmed, your booking remains stored—even if the system crashes right afterward.
Summary
The ACID properties are essential to ensure that:
- Transactions are complete and reliable (Atomicity),
- Data integrity is preserved (Consistency),
- Concurrent operations don’t conflict (Isolation),
- And once done, changes cannot be lost (Durability).