ACID
- Atomicity. A transaction is atomic: all of its writes land, or none do: the transfer that cannot half-happen.
- Consistency and durability. Durability means a committed write survives the crash that follows it: the D in the promise.
- BEGIN and COMMIT. BEGIN opens the transaction, COMMIT lands it, ROLLBACK abandons it: three words that fence correctness.
Isolation and Concurrency
- Why isolation. Isolation decides what concurrent transactions see of each other: the source of the subtlest bugs in commerce.
- Read phenomena. Levels trade off anomalies: dirty reads, non-repeatable reads and phantoms: each level forbids more.
- Choosing a level. Most systems live at READ COMMITTED; money paths often need SERIALIZABLE plus retry-on-conflict.
Locks, Deadlocks and Transaction Design
- Locking. Writes take locks; readers and writers queue behind them: long transactions turn queues into outages.
- Deadlocks. A deadlock is two transactions each waiting on the other’s lock: engines kill one, and your code must retry.
- Short transactions. Design transactions short: gather data first, then lock, write and commit fast: never hold locks across user think-time.
Before and after this level
- Before: Level 8: Schema Design: Tables and Data Types, Keys and Constraints, Normalisation and Relationships.
- Next: Level 10: Indexes & Query Planning: Index Structures, Query Execution Plans, Diagnosing Slow Queries.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does SQL Level 9: Transactions cover?
ACID, Isolation and Concurrency, Locks, Deadlocks and Transaction Design: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 8: Schema Design, which covers Tables and Data Types, Keys and Constraints, Normalisation and Relationships.