How a backend reads and changes data safely: transactions under concurrency, then the SQL you write every day (joins, GROUP BY, window functions). The joins, GROUP BY and window pages use the same small food-delivery database (customers, restaurants, orders, menu items), with the SQL and the Drizzle (TypeScript) version side by side and the table shown after each step. The transactions page uses a small shoe shop instead.
Reading order
- Quick revision: the whole subject on one page, for the night before an interview.
- Transactions and concurrency: lost updates, isolation levels, FOR UPDATE vs SERIALIZABLE and retry. (detailed)
- Joins: inner join, left join, and finding rows with no match. (detailed)
- Aggregates: GROUP BY and HAVING: piles, count(*) vs count(col), WHERE vs HAVING. (detailed)
- Window functions: top N per group with rank, running totals, LAG. (detailed)