Chapter 9. The Diwali Dress Rehearsal
Database design that stays fast: schemas, indexes, N+1

Chapter title card with the chapter's host character and the day of the countdown.
What you'll learn in this chapter
- Design a data model before building features, and ask Claude for a good one
- Apply the core rules: one fact in one place, keys, the right types, owner columns
- Find and fix the four classic slowdowns: missing indexes, N+1 queries, loading everything, slow RLS
- Read a simple EXPLAIN plan and measure before and after
- Sketch a multi-tenant schema so QueueLess can serve more than one café
Inside
- Schema first, features second
- The rules of a tidy pantry
- Why the rehearsal collapsed: four slowdowns
- One app, many cafés: multi-tenant design
- Growing up: habits for a database with real customers
- Your turn: survive the rehearsal rerun
- What you've learned
Checking your ticket at the door…