Full answer
- Atomicity. The engine logs changes so it can undo an incomplete transaction. A crash halfway through a transfer leaves both accounts unchanged.
- Consistency. Constraints, foreign keys and triggers are enforced, so a committed state never violates the declared rules. Application-level rules, such as "total money in the system is unchanged", are the application's job, helped by atomicity.
- Isolation. Each transaction behaves as if it ran with less interference from others. Weaker levels allow specific anomalies in exchange for concurrency; SERIALIZABLE aims for results equivalent to some serial order.
- Durability. The commit is written to stable storage (a write-ahead log or journal) before success is reported. Settings such as SQLite's
PRAGMA synchronous = OFFor PostgreSQL'ssynchronous_commit = offtrade some durability for speed.
A common interview follow-up is that the C in ACID differs from the C in the CAP theorem, which is about replicas agreeing.
Key points
- Atomicity: all or nothing
- Consistency: constraints hold after every commit
- Isolation: controlled visibility between concurrent transactions
- Durability: committed data survives crashes
Common mistakes
- Describing consistency as 'data is correct' without mentioning constraints
- Assuming every isolation level prevents every anomaly
Follow-ups
- Which anomalies does READ COMMITTED allow?
- How does a write-ahead log provide durability?
Tips
- Give one example per letter