chapter seven

7 Schema: A fossilized argument

 

This  covers

  • The schema: the most stable map of what an app remembers
  • Pointing AI at any repo to find its schema file
  • Letting AI draw it as an ERD and tour the core tables
  • Tracing one user action across its tables with AI
  • Asking AI to read composite indexes as the app's hottest queries
  • Mining the migration history for the roadmap in one AI prompt

In part 2, you asked why a product exists; now in part 3, we'll ask what it actually is. The best place to start is the schema, because it is the most stable layer of the stack. Imagine it is your second week on a new team, and your first task is to add a CSV export button. You open the repository and find the schema.prisma file (Prisma is a schema-first ORM for Node.js and TypeScript). Inside, you face 119 model blocks, over four hundred fields, and dozens of @relation decorators. You spot a User and an Account, a Team and two kinds of Membership, a Profile, and a confusing cluster of Booking tables (Booking, BookingReference, BookingSeat, BookingTimeStatus_view). You have no idea which table to query for your export. The senior engineer is stuck in a meeting, and when you ask an AI, it confidently hallucinates three tables that do not exist. By lunch, you've read forty files, and you still don't have a working mental model of the data.

7.1 A schema is a tidy stack of spreadsheets

7.2 A schema's shape changes with the kind of codebase

7.3 Find the schema file before you can read it

7.4 Ask the LLM to draw the schema and tour it

7.5 Trace one user action across the tables

7.6 Open one table and read its columns and indexes

7.7 Mine the migration folder for the roadmap

7.8 Summary