Sub topic 6
Modeling your data
This chapter covers how to design the data behind your MVP: tables, fields, relationships, ownership, and access rules. It assumes you have already scoped a single core user flow and picked a tool, and that you know what a form, a list page and a sign-in are.
Why data comes before screens
Every screen in a no-code or AI-built app is a view of stored data. If the data model is wrong, you will rebuild screens, workflows and permissions later. Changing a field name is cheap in week one and expensive after real users have entered data.
Model only what your core flow needs. For the TaskNest example (freelancers tracking client tasks), the flow is: sign in, create a task, see only your own tasks, mark one done. That needs one table.
Entities, fields and types
An entity is a kind of thing your app stores, such as a task or a user. Each entity becomes a table (in a database) or a data type (in a no-code builder). A field is one attribute of that entity, and each field has a type such as text, number, date or true/false.
Work in this order:
- List the nouns in your core flow. These are candidate entities.
- For each entity, list the fields the flow reads or writes.
- Choose a type for each field.
- Mark which fields are required.
- Decide who owns each row.
| Field | Type | Required | Note |
|---|---|---|---|
| id | unique id (uuid) | yes | Generated, never typed by users |
| owner_id | reference to user | yes | Drives access rules |
| title | text | yes | |
| client_name | text | no | Plain text is enough for an MVP |
| due_date | date | no | |
| status | one of todo, doing, done | yes | Restrict allowed values |
| created_at | timestamp | yes | Set automatically |
Restricting status to a fixed set of values prevents typos like "Done" and "done " from creating separate groups in your list.
Relationships
Entities usually connect. The three shapes you will meet:
- One-to-many: one user has many tasks. The "many" side stores a reference to the "one" side (
owner_id). - Many-to-many: a task involves many tags, and a tag applies to many tasks. This needs a third "join" table holding pairs of ids.
- One-to-one: a user has one profile. Often better as extra fields on the user.
A common MVP mistake is to create a separate clients table before you need it. TaskNest stores client_name as text. Promote it to its own table only when you need client-level data, such as an email address or a hourly rate. Until then, the extra table adds a join, a form and a permission rule for no tested benefit.
Ownership and access rules
Decide ownership while modeling, not after. Every row that belongs to a user should carry an owner field. Without it you cannot express "users see only their own data", and retrofitting it means back-filling every existing row.
Where the rule is enforced matters:
| Enforcement point | Strength | Failure mode |
|---|---|---|
| Hidden in the UI (filter or hidden button) | Weak | Anyone calling the API directly sees all rows |
| Backend rule in the no-code tool | Medium | Misconfigured per-page or per-workflow rules leave gaps |
| Database policy (row-level security) | Strong | Forgetting to enable it leaves the table open |
On a Postgres backend such as Supabase, row-level security (RLS) makes the database itself check ownership on every query:
create table tasks (
id uuid primary key default gen_random_uuid(),
owner_id uuid not null references auth.users(id),
title text not null,
client_name text,
due_date date,
status text not null default 'todo' check (status in ('todo', 'doing', 'done')),
created_at timestamptz not null default now()
);
alter table tasks enable row level security;
create policy "owners read own tasks" on tasks
for select using (auth.uid() = owner_id);
create policy "owners insert own tasks" on tasks
for insert with check (auth.uid() = owner_id);
create policy "owners update own tasks" on tasks
for update using (auth.uid() = owner_id) with check (auth.uid() = owner_id);Read the policies closely. using filters which existing rows a user can touch. with check validates the new row values. The update policy needs both, so a user cannot reassign their task to someone else by changing owner_id. There is no delete policy, so deletes are denied for everyone. That is a safe default, but you must add a policy if the app needs deletion.
Common errors
- Storing lists in one text field. "tag1, tag2, tag3" in a single cell cannot be filtered or counted reliably. Use a join table or the tool's list type.
- Free text where a fixed set belongs. Use a constrained status or option field.
- Copying the same value everywhere. If a client's name is typed into fifty tasks, fixing a misspelling means fifty edits. This is the signal to create a clients table.
- Using names or emails as identifiers. People change both. Use a generated id and treat other fields as data.
- Missing timestamps. Without
created_atyou cannot answer later questions such as how many tasks users created in their first week. Metrics chapters depend on this. - Storing data you do not need. Every extra personal field adds privacy duty. Collect only what the flow uses.
- Trusting the AI builder's schema. Generated schemas often omit owner fields, constraints or policies. Compare the result against your own table before you accept it.
Planning for change
Your first model will be wrong in places. Reduce the cost of that:
- Add new columns instead of renaming or repurposing old ones. Existing rows and screens keep working.
- Make new columns optional first, then back-fill, then make them required.
- Keep a short written description of the model. It is the input to your AI builder prompt and your record if you move platforms later.
- Export a sample of your data early. Knowing you can get it out is part of managing lock-in.
Exercises
Exercise
A teammate hides other users' tasks by filtering the list page to owner_id = current user. The table has no database rules. Why is this not enough, and what should you add?
Show answer
The filter runs in the UI, so anyone who calls the data API directly can request every row. Enforce ownership at the data layer, for example with row-level security policies on the tasks table (select, insert and update checking auth.uid() = owner_id), or the equivalent backend privacy rule in your no-code tool.
Exercise
TaskNest users now want to attach several tags to each task and reuse tags across tasks. Which relationship is this, and what table structure do you need?
Show answer
It is many-to-many. Create a tags table (id, ownerid, name) and a join table such as `tasktags` (taskid, tagid), with one row per pairing. The join table also needs ownership rules, for example by checking that the related task belongs to the user.