DBMS & SQL
Joins, indexes as B+ trees, transactions, isolation levels, normalization vs pragmatic denormalization. Write real SQL — window functions included.
The mental model
A database is a library with a very good catalogue and a very strict lending policy.
The books are your rows, stored on shelves (disk pages) in whatever order they were shelved. Finding a book by walking every shelf is a sequential scan — fine for a small library, ruinous for a national one. The catalogue is an index: a separate, sorted structure that maps "title starts with M" to a shelf location in a handful of steps. The catalogue is not free — every new book must also be filed, so writes get slower as you add catalogues, and a catalogue nobody searches is pure overhead.
The lending policy is the transaction system. Two people cannot check out the same book simultaneously; if the librarian is midway through a two-book loan and the fire alarm goes off, either both books are on loan or neither is — never one. That is atomicity. The rules about what a second reader may see while a loan is in progress are isolation levels, and they are a dial, not a switch: stricter means more correct and slower, looser means faster and subtly wrong in ways that only appear under concurrency.
**Why this exists in interviews.** Almost every backend system is a database with an API in front of it, so database intuition is the highest-leverage CS-core topic there is. Good interviewers do not ask "what is an index" — they ask "why did the planner skip yours", because the first question tests vocabulary and the second tests mechanism. The one idea that unlocks most of it: **an index is a sorted structure, so it can only help when your query preserves that sort order** — which explains leading-column rules, leading-wildcard failures, function-wrapped columns, and why ORDER BY sometimes becomes free.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision