ACID & Transactions
A transaction is a logical unit of work. ACID properties guarantee correctness even with crashes and concurrency.
Cheat sheet
- ▸Atomicity: all or nothing (undo log).
- ▸Consistency: moves DB from one valid state to another (constraints hold).
- ▸Isolation: concurrent transactions behave as if serial.
- ▸Durability: committed data survives crashes (redo log / WAL).
- ▸States: Active → Partially committed → Committed, or → Failed → Aborted.
- ▸COMMIT makes changes permanent; ROLLBACK undoes them.
ACID and who enforces it
| Property | Meaning | Mechanism |
|---|---|---|
| Atomicity | All or nothing | Undo logs |
| Consistency | Rules always hold | Constraints, app logic |
| Isolation | No interference | Locks / MVCC |
| Durability | Survives crash | WAL / redo logs |
Top 10 campus interview questions
Quick quiz
1. 'All or nothing' is:
2. Durability is ensured by:
3. 2PL guarantees:
4. Serializability is tested with a:
5. Strict 2PL prevents: