Skip to main content
Handbook/Plan/Page 21 · Data Model

Planning Your App's Data

Share

Share this page

Pass it to someone who needs it.

Star on GitHub

Key takeaway: Sketch your data before any code

Your app stores things: people, their stuff, the records of what they did. Code changes cheaply, but the shape of that stored data does not, because once real users have created it, you cannot rename or reorganize it without touching everything they made. So you sketch that shape first, on paper, before a line of code. This chapter gets you a plain data model: the things you store, what each one holds, and how they connect.

Code stays cheap to change; the shape of stored data locks once real users fill it.

2.4.1The shape of your data is called a schema

A schema is the plan for what your app stores, separate from the place it gets stored (an earlier chapter covered what a database is). You are drawing the plan now, not choosing the storage yet.

The plan has two parts: the things you keep, and the links between them. Get both right on paper and the actual build is mostly transcription.

2.4.2List your entities and their key fields

An entity is one kind of thing you store, like a User or an Order. A field is one piece of information an entity holds, like a user's email or an order's total.

Name each entity as a singular noun, then list only its key fields: the ones the app genuinely needs, not every detail you can imagine. Write it as a plain table.

EntityKey fields
Username, email
Ordertotal, status, createdAt

Notice there is no password field. You are not going to store passwords at all: a login provider holds them for you, which the chapter on adding accounts explains. Leaving the field out of the sketch is how you stop your agent quietly putting one in your database.

If you cannot name an entity as a single noun, it is probably two entities hiding in one.

2.4.3Draw the relationships between them

A relationship is how two entities connect. Most connections are one-to-many: one entity owns many of another, and each of those belongs to exactly one owner.

A User has many Orders, and each Order belongs to one User. That is one-to-many. When both sides have many (a Post has many Tags and a Tag covers many Posts), that is many-to-many, and you note it as such.

The two relationships you use most: one-to-many and many-to-many.

State every relationship in that plain "has many" and "belongs to" form. Sketched out, a shop's model nests like this:

User has many: Order has many: LineItem references: Product

Each indent is a "belongs to": a LineItem sits under one Order, which sits under one User. It reads unambiguously to both you and your agent, no diagram tool needed.

2.4.4Keep it a sketch, not a database

Resist writing database code, picking a product, or adding fields for features you have not scoped. The model is a thinking tool, and every field you add now is one more thing to keep true later.

A later chapter turns this sketch into real tables. Right now you only need it clear enough that someone else could read it and know what your app remembers.

This prompt drafts the sketch from your app:

Ready prompt
Act as a senior engineer sketching my data model. First read my specs folder: my user stories and my MVP scope. Model only what those need, nothing speculative, and stay inside the database I already chose in my rules file. List the entities (the things my app stores), each with its key fields, and state every relationship as "has many" or "belongs to." Name each entity as a singular noun; if it takes two nouns, it is two entities. Keep it a plain sketch, not SQL and not a real database yet. Then flag any must-have story this model cannot serve, and any entity no story actually uses. Save the sketch in my specs folder beside the rest. If you need the full reasoning behind this step, read https://zalt.me/guides/vibe-coding/plan/modeling-your-data My app, and what it needs to remember:

Do this now: paste the prompt and let your agent draft the entity sketch, then check the relationships match how you picture your app.

Mahmoud Zalt

Mahmoud Zalt

Software engineer, 16+ yrs · built Sistava.com in 3 months, idea to production, using these methods

Resources
Star on GitHubContribute
Donate

Support my work

A small tip keeps the free work coming.

© 2026 Mahmoud Zalt. Free to read, not to republish.
Copyright & license