What is Transactions & ACID?
Transactions and ACID, told as a story about the four promises a receipt must keep.
The power cut out — only half of the receipt's work got done.The box is gone but the ledger still shows it.
A half-done job leaves a ledger nobody can trust.The ledger and the real boxes disagree, so the next person can't trust it.
ACID is the four promises every receipt must keep.Only a receipt keeping all four can truly be trusted.
Each of ACID's four letters stands for one promise.Isolation is fine-tuned via isolation levels.
Fully keeping ACID makes the ledger trustworthy, but receipt processing can slow down.Ledger safety and processing speed often trade off.
ACID is the four promises a receipt (transaction) must keep: atomicity, consistency, isolation, durability.
A transaction is an indivisible unit of work in a database, and ACID is the set of four properties that make it safe: Atomicity (all succeed or all fail), Consistency (constraints are preserved), Isolation (concurrent transactions don't interfere), and Durability (committed results persist permanently). Isolation's strength is tuned via isolation levels.
When grown-ups say it
- Transaction
- One receipt's unit of work. The smallest unit that can't be split further.
- Atomicity
- All or nothing. No stopping halfway.
- Consistency
- Never breaking the ledger's rules. Always honors the constraints.
- Isolation
- Not bleeding into someone else's work. Fine-tuned by isolation level. → how much to hide when hands overlap
- Durability
- Once stamped, it never disappears. Stamped records survive even a power outage.
- Concurrency Control
- The method that stops simultaneous edits colliding. How isolation is actually implemented. → the no-collision rule
- In-Memory DB
- A desk that skips the deep shelf and serves from memory. Sometimes trades off durability for speed. → the express pickup desk
- NoSQL Modeling
- A warehouse reshaping shelves to fit the box. Many products don't keep ACID as strictly as the relational warehouse. → the free-shelf warehouse