Recap and Practice
Key takeaways
- Most apps need only one of three storage shapes — relational, document, or key-value — and relational is the safe default.
- Start with a managed ; you keep the data and the schema decisions, the platform keeps the servers running.
- Good schema design means honest types, foreign keys and constraints, sensible indexes, and no duplicated data.
- Treat every migration as a one-way door: back up before anything that drops or renames, and review AI-written migrations closely.
- Always demand parameterized queries so user input is never concatenated into .
Try it
Pick a tiny app idea and write out its entities and relationships in plain English first. Then hand that description to AI and ask for a schema plus a forward migration — and review the result against this chapter's checklist before running anything.
Design a relational schema for a personal bookmarks app.
Entities and relationships:
- A user has many bookmarks.
- A bookmark belongs to one user, has a URL, a title, and many tags.
- A tag can apply to many bookmarks.
Requirements:
- Use UUID primary keys and created_at timestamps.
- Enforce relationships with foreign keys.
- Add indexes for the columns we'll filter on.
- Give me the schema as SQL plus a forward migration file.
- Flag any migration step that drops or renames so I can back up first.