23 topics · interview-ready · SQL-heavy
Databases, from ER diagram to query plan
A database is a bet that the same data will be asked different questions for decades. Everything here — normalisation, indexing, transactions, recovery — exists to make that bet safe, and each one has a price you should be able to name.
How to study DBMS
DBMS is the highest-yield of the four subjects for most backend interviews, because it's the one you'll be asked to do rather than describe — write this query, explain this plan, design these tables.
- Write SQL by hand, on paper. Not in an editor with autocomplete. Interviews ask for joins, aggregates and window functions written cold, and the gap between reading SQL and producing it is enormous. Three queries a day beats an hour of reading.
- Learn the internals through
EXPLAIN. B+ trees, buffer pools and join algorithms feel abstract until you see the planner choose a hash join over a nested loop and can say why. Every internals topic here connects to something a query plan shows you. - For every guarantee, ask what it costs. Serialisable isolation costs throughput and retries. An index costs write speed. Normalisation costs joins. Durability costs an fsync. Interviewers grade the tradeoff, because anyone can name the feature.
Three things, in order of weight: can you write correct SQL under mild pressure; can you reason about why a query is slow and what index would fix it; and do you understand what a transaction actually promises when two users hit the same row. Definitions of 3NF matter for written exams; those three matter for the job.
The 23 topics
Modelling — getting the schema right
SQL — the part you'll be asked to write
Internals — why your query is slow
Transactions — what happens when two users collide
The interview section has a 64-question bank with answers, ten SQL problems with solutions (the format most rounds actually use), a query-tuning drill, and the schema-design walk-through.
The 23-day plan
One topic a day. Tick a day when you can explain it out loud and name what it costs. Progress is stored in this browser only.
The one big idea
Everything in this subject is one of four bargains. Naming which bargain a feature belongs to is how you sound like you understand it rather than remember it.
Numbers worth memorising
The mistakes that cost marks
- "
WHERE x = NULLfinds the null rows." It finds nothing —NULLcomparisons are UNKNOWN. UseIS NULL. - "Indexes make the database faster." They make reads faster and every write slower.
- "Normalise as far as possible." Normalise to 3NF/BCNF by default, then denormalise deliberately where reads demand it.
- "
DELETEandTRUNCATEare the same." Truncate is DDL, doesn't fire row triggers, and can't be filtered. - "Serialisable just means slower." It also means retryable failures your application must handle.
- Confusing a candidate key with the primary key.
- Saying "it's in 3NF" when the example actually violates BCNF.
- Mixing up
WHEREandHAVING. - Treating a view as if it stored data (it doesn't; a materialised view does).
- Calling MVCC "a kind of locking" — its whole point is that readers don't lock.
- Saying "NoSQL is faster" without naming which operation.
"I'd add a composite index on (customer_id, created_at) in that
order, because the query filters on customer and sorts by date — so the index
satisfies both the lookup and the ordering, and the planner can stop early on the
LIMIT. The cost is that this table takes 2,000 writes a second and
every one now maintains an extra index, so I'd check whether an existing index
already covers the prefix before adding another."