Stage 2 · Lesson 7 of 10
Transactions and ACID
A groups several statements so they all succeed or all fail together. Moving money between accounts is two updates: take it from one, add it to the other. Without BEGIN and COMMIT, a crash between them loses money.
ACID names the four guarantees. Atomic means all or nothing. Consistent means your constraints still hold.
Isolated means transactions running at the same time do not see each other's half-done work. Durable means committed data survives a crash. Keep transactions short.
Never wait on a network call or a user inside one, because locks are held until it ends. Frameworks usually open one per request or per unit of work.
Common trapreading a value, deciding in code and then writing: another request can change the row in between.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Relational Database Design and Modeling
Design Gurus · Intermediate · $98 one-time
The modelling and normalisation decisions that stay with a codebase for years
- CourseFreeCS50's Introduction to Databases with SQL
Harvard University · Beginner
Free course from querying through schema design, indexes, transactions and scaling
Practise
Also worth your time
- Database Indexing Explained: B-Tree, Hash, Bitmap, R-Tree, and When to Use Each (opens in a new tab)Read
B-tree and composite indexes, plus the leftmost-prefix rule that trips people up
What sits under your queries: storage engines, transactions and isolation levels