Almost everything in an application can be changed cheaply. The shape of the data cannot, once real data exists in it, which is why an hour spent on this before building is worth more than an hour spent on anything else.
What are you actually deciding?
What things exist, what each one records, and how they relate. Three or four entities cover most first versions, and getting those roughly right removes an enormous amount of later pain.
Everything else is a screen, and screens are easy to change.
How do you work it out?
Describe what the app does in a paragraph and underline the nouns. Those are your entities, and the verbs connecting them are usually the relationships. It is a crude method and it works remarkably well for anything small.
Naming things carefully at this stage also pays off, since table and column names propagate into code, queries and eventually into anything anybody exports, and renaming them later touches every one of those.
What decisions are expensive later?
- Whether something can have many of another. Changing one to many is painful.
- What is required. Adding a required field to existing rows needs a decision about every one.
- How you identify things. Changing an identifier scheme is disruptive.
- Whether you keep history. Deleted rows cannot be recovered later.
- Time zones and dates. Stored badly, this is genuinely miserable to fix.
What is the most common regret?
Deleting rather than marking. An application that removes records permanently cannot answer questions about what happened, cannot undo a mistake, and cannot show anybody what changed. Marking something as removed instead costs one column.
How should you use AI here?
Here is what my app does. Propose a data model with the fewest tables that would work. For each table say what it holds and why it is separate. Then tell me which of these decisions would be expensive to change once there is real data, and what would break if I got each one wrong.
The second half is where the value is, since a proposed model is easy and knowing which parts are load-bearing is not.
What do generated models get wrong?
Elaboration. Advice drawn from published examples produces normalised structures appropriate for large systems, so a project with three concepts receives nine tables with join tables between them.
Asking for the simplest model that works, then asking what it would cost to simplify further, produces something a person can actually hold in their head.
Indexes are worth adding for anything you filter or sort by regularly, since a query that is instant on a hundred rows can become noticeably slow on a hundred thousand without any code changing.
How do you handle changes once it is live?
With migrations, which are versioned scripts that change the structure and are kept alongside the code. Changing a live database by hand is how environments drift apart and how a deployment stops matching what is running.
This is worth setting up from the start, since retrofitting it is awkward.
What should you store about time?
The moment something happened, in a single reference standard, converted for display rather than at storage. Storing local times without knowing the zone is the mistake that produces an unfixable mess, because the information needed to correct it was never recorded.
The clocks changing is what exposes it. An application storing local times has an hour that occurs twice and an hour that does not exist, and any calculation across that boundary is wrong. This is one of the clearest cases where a decision made in ten seconds at the start saves a genuinely miserable afternoon later.
What is the sanity check?
Write out three real examples by hand, including an awkward one. If your model cannot represent something that genuinely happens, that is far cheaper to discover now than after a hundred rows exist.