Designing the data model
The builder will propose tables for you. That is a good start, but the data model is the one part of a SaaS that is painful to change later: once customers have data in it, every change is a migration. Spend an hour now to understand and check it. In this lesson you design the Bookwise data model on paper, learn the three rules that matter most for a multi-customer product, and use Claude to check what the builder generated.
Think in things and relations
A data model is a list of things (tables) with properties (columns) and relations between them. Start from the nouns in your core flow:
Owner signs up, creates the salon, adds services and staff, a client books an appointment.
Add the things the platform needs anyway: users (people who log in) and the subscription of the salon.
The Bookwise model
| Table | Key columns | Relations |
|---|---|---|
salons | id, name, slug, address, time_zone, created_at | has many staff, services, appointments |
users | id, email, password_hash, name | belongs to salons through memberships |
memberships | id, salon_id, user_id, role (owner / staff) | links users to salons |
staff | id, salon_id, user_id (optional), name, active | belongs to a salon |
working_hours | id, salon_id, staff_id, weekday, start_time, end_time | belongs to staff |
services | id, salon_id, name, duration_min, price_cents, active | belongs to a salon |
clients | id, salon_id, name, email, phone | belongs to a salon |
appointments | id, salon_id, staff_id, service_id, client_id, starts_at, ends_at, status, cancel_token | belongs to a salon, staff, service, client |
subscriptions | id, salon_id, stripe_customer_id, stripe_subscription_id, status, current_period_end | belongs to a salon |
A few choices worth explaining:
- Memberships instead of a
salon_idon users: one person may later work for two salons, and roles live on the link, not on the person. - Staff separate from users: a salon can list a stylist who never logs in.
user_idis filled only when they get a login. - Prices in cents (
price_cents, an integer): never store money as a floating-point number; 0.1 + 0.2 is not 0.3 in a computer. starts_atandends_atin UTC, with the salon'stime_zone(for exampleEurope/Amsterdam) to show them correctly, including across daylight saving changes.statuson appointments (booked, cancelled, no_show, completed): you do not delete appointments, you change their status. History matters.
Rule 1: every customer row has a tenant
Bookwise is multi-tenant: many salons share one app and one database. The salon is the tenant. Every table with customer data carries salon_id, and every query filters on it.
Why so strict? The most common serious bug in small SaaS products is one customer seeing another customer's data, because one query forgot a filter. If salon_id is on every row, you can:
- check it in every query ("WHERE salon_id = the current user's salon");
- add a database rule that enforces it (in PostgreSQL, row-level security can do this);
- export or delete all data of one customer when they leave (GDPR).
Never take the tenant from what the browser sends ("salon_id=42" in a form or URL) without checking that the logged-in user is a member of salon 42. Take it from the session and the memberships table, on the server.
Rule 2: let the database protect the rules that matter
Some rules are too important to leave to application code alone, because two requests can arrive at the same millisecond.
For Bookwise the most important one: a staff member can never have two overlapping appointments. Options, from strongest to weakest:
- An exclusion constraint in PostgreSQL: the database refuses an appointment whose time range overlaps another booked appointment of the same staff member.
- A transaction with a lock: lock the staff member's row, check for overlaps, insert, commit.
- A check in the code only: works in testing, fails the first Saturday morning two clients click at once.
Other constraints to add:
services.duration_min > 0;appointments.ends_at > appointments.starts_at;- a unique
salons.slug(it is in the public booking URL); - a unique
(salon_id, user_id)in memberships; - foreign keys, so an appointment cannot point to a service that does not exist.
Rule 3: plan for change and deletion
Ask for every relation: what happens when the parent is removed?
- A service is retired: set
active = false; old appointments still point to it. - A staff member leaves: set
active = false; move or cancel their future appointments first. - A salon cancels the subscription: keep data for a grace period, then delete everything with that
salon_id(and tell them in your terms how long you keep it).
Soft deletes (an active flag or deleted_at column) are usually right for business data. Hard deletes are right for personal data you are obliged to erase.
How long you may or must keep personal data and invoices differs per country. GDPR applies in the whole EU (and the UK GDPR in the UK), but retention periods for business records are national: check with your data protection authority (for example the Autoriteit Persoonsgegevens in the Netherlands, UODO in Poland, the ICO in the UK) and your tax authority. The course Legal and compliance for online business covers privacy policies and DPAs.
Indexes: only the obvious ones for now
You do not need to be a database expert. Make sure these exist, because the core flow uses them all day:
appointments (salon_id, staff_id, starts_at): the day view and the slot calculation;services (salon_id),staff (salon_id),clients (salon_id, email);appointments (cancel_token)unique: the cancel link in the email.
Check the builder's model with Claude
After your first build, the code and schema live in your app's git repository (every app is a private repo at gitlab.my-app.engineer/tenants/<your-username>/<app>) and you can open it from the App hub. With the Claude connector and the Read files permission, Claude can read the files in your workspace. Where exactly the generated schema file sits depends on the stack the builder chose; ask Claude to find it.
Use my my-app.engineer workspace. Find the database schema or migration files of my app [app name] and do not change anything. Then: 1. List every table with its columns, relations and constraints. 2. Compare it with this intended model: [paste your table list]. 3. Flag every table with customer data that has no salon (tenant) column. 4. Tell me whether a double booking of the same staff member is prevented by the database itself or only by code. 5. Flag money stored as floating point and times stored without time zone. Give me a short list of recommended changes, most important first.
Then bring the most important changes back to the builder's manager chat as one clear request, or let Claude make them in a later iteration (module 2 shows how to do that safely).
Bookwise
The first build had a bookings table without a staff column ("anyone" was the only option) and stored price as a decimal number of euros. The founder asked the manager: "Add staff_id to bookings, rename it appointments, store prices as integer cents, and add a database rule that one staff member cannot have overlapping booked appointments." The next build did exactly that.
Draw your own table list with columns, relations and at least three constraints. Mark the tenant column in every customer table. After your first build, run the Claude prompt above and write down the differences.
This course is general information, not personal legal, tax or financial advice. Rules, amounts and dates change: check the official source for your country before you act.