Appearance
ACID Properties
These are the 4 properties that guarantee database transactions are processed reliably.
A — Atomicity: "All or nothing"
A transaction either completes fully or doesn't happen at all. If any step fails, the entire transaction is rolled back.
Example: Transfer ₹500 from Account A → B
- Debit A: ✅
- Credit B: ❌ (system crashes)
Atomicity ensures the debit is also rolled back. Money doesn't vanish.
C — Consistency: "DB must go from one valid state to another valid state"
A transaction must leave the database in a consistent state — all rules, constraints, and cascades must hold.
Example: If a rule says "balance can't go negative", a transaction that would cause that must fail entirely.
I — Isolation: "Concurrent transactions don't interfere with each other"
Even if 100 transactions run simultaneously, each should behave as if it's running alone.
Example: Two people booking the last seat on a flight simultaneously — isolation ensures only one succeeds.
Handled via isolation levels (Read Uncommitted → Serializable).
D — Durability: "Once committed, data is permanent"
Even if the system crashes right after a commit, the data will not be lost. Typically ensured via write-ahead logs (WAL) or disk writes.
Summary Table
| Property | Core Idea | Guaranteed By |
|---|---|---|
| Atomicity | All or nothing | Rollback / Undo logs |
| Consistency | Valid state always | Constraints, Triggers |
| Isolation | No interference | Locks, MVCC |
| Durability | Committed = permanent | WAL, Disk flush |
Interview Follow-up: "Which property is hardest to achieve?" → Isolation, because it has a direct tradeoff with performance, which is why multiple isolation levels exist.