SQL mastery
Joins, aggregation, window functions, CTEs. Backend loops at product companies almost always include a live SQL round — write it, not just read it.
The mental model
SQL is asking questions of a spreadsheet so large and so consistent that no human could scan it. You do not tell the database how to find the answer — you describe the answer you want (which rows, grouped how, ordered how) and the query planner figures out the mechanics. That declarative gap is the whole point: you say "the ten most recent orders per customer this quarter" and the engine decides whether to use an index, a hash join, or a sort.
The single mental shift that separates people who write SQL from people who *think* in SQL: stop thinking row-by-row and start thinking in sets. A loop in application code that does "for each user, run a query" is almost always one set-based query the database can answer far faster, because the engine can join, hash, and sort millions of rows with algorithms you would never hand-write.
**Why this exists — what breaks without it.** Teams that treat SQL as "the thing the ORM generates" ship the N+1 disaster (one query becomes one-plus-a-thousand), pull entire tables into application memory to filter them in a for loop, and reach for a NoSQL store the moment they need a second access pattern — when a GROUP BY and an index would have answered it. They cannot write the query a live interview asks for, because they have only ever read SQL, never composed it. The relational model with SQL on top is the most battle-tested data tool in existence; the join, the aggregate, and the window function are the levers, and not owning them means paying for them in application code that is slower, buggier, and harder to change.
Product-company backend loops almost always include a live SQL round — you write it on a shared screen, not multiple-choice. This lesson is about being able to.
- 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