ACID Properties:
ACID is the set of properties that guarantee correctness of database transactions, especially in the presence of concurrent execution and system failures.
A — Atomicity:
A transaction is an indivisible unit — either all its operations complete successfully (commit) or none of them take effect (abort/rollback). Partial execution is never visible.
Implemented by: Write-Ahead Logging (WAL) — the undo log allows rolling back incomplete transactions after a crash.
Example: Transfer $500 from A to B: debit A AND credit B must both happen or neither happens.
C — Consistency:
A transaction transforms the database from one consistent state to another consistent state. It must respect all integrity constraints (PK, FK, CHECK, domain constraints).
Implemented by: Application logic + integrity constraints. The DBMS enforces structural constraints; the application must ensure business rule consistency.
Example: After a transfer, the total balance in the system must remain the same.
I — Isolation:
Concurrently executing transactions must appear to execute serially — as if no other transaction is running. Intermediate states of a transaction are invisible to other transactions.
Implemented by: Two-Phase Locking (2PL) or MVCC (Multi-Version Concurrency Control).
Example: If T1 is transferring funds, T2 should see either the pre-transfer or post-transfer balances — not the intermediate state where A is debited but B is not yet credited.
D — Durability:
Once a transaction commits, its changes are permanent — even if the system crashes immediately afterward.
Implemented by: Redo log + stable storage. Committed data is written to non-volatile storage (disk) before the commit is acknowledged.
Example: After a successful bank transfer commit, the new balances survive even a power failure.