Stage 2 · Lesson 8 of 11
Isolation levels and locking
decide what transactions running at the same time can see of each other. 's default is Read Committed. Each statement sees data committed before it started, so two reads in one transaction can return different values.
Repeatable Read gives the whole transaction one fixed snapshot of the data. Serializable makes transactions behave as if they ran one at a time, but some will fail and must be retried. For "check, then update" logic you have two options.
You can lock the row with SELECT ... FOR UPDATE. Or you can use optimistic locking: a version column that the UPDATE checks has not changed. Without either, you risk a lost update, where one write silently overwrites another.
Common trapchoosing Serializable everywhere without retry code; failures are expected under it, and the application must run the transaction again.
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