What is a database schema?
The schema decides what your app can store and how pieces connect. Here is a real example, the rules that keep it clean, and the mistakes that hurt later.

Key takeaways
- A schema defines tables, their columns and types, required fields, and how tables relate through keys.
- One table per kind of thing, one row per item, and links by ID instead of copied data.
- Schemas change through migrations, so it is normal for one to grow with the app.
Your database schema is the blueprint of the data: which tables exist, which columns each has, what type of value each column holds, which fields are required, and how tables point at each other. The data itself is the rows; the schema is the shape every row must fit.
A paper filing cabinet makes it concrete. The schema is the decision that there is one drawer for clients and one for appointments, that every appointment card has a date, a time and a client number, and that the client number points to a card in the clients drawer. Without that agreement, the cabinet fills with notes nobody can search.
A worked example: a small booking app
- profiles: id, full_name (text, required), phone (text), created_at (timestamp).
- services: id, name (text, required), duration_minutes (integer, required), price_cents (integer, required), active (boolean, default true).
- bookings: id, profile_id (links to profiles), service_id (links to services), starts_at (timestamp with time zone, required), status (one of pending, confirmed, canceled), notes (text).
A few choices in there are deliberate. Prices are whole cents so arithmetic never produces 19.999999. Times carry a time zone, because "10:00" means nothing across borders. Status is limited to three values so a typo cannot invent a fourth. And bookings store service_id rather than a copy of the service name, so renaming a service fixes every booking at once. The links between tables use primary and foreign keys, which the database enforces: a booking cannot point at a service that does not exist. See how to build a booking system for the full app.
Rules that keep a schema healthy
- 01One table per kind of thing. Users, products, orders. If a table has columns like item1, item2, item3, it wants to be a second table.
- 02Store facts once. Copying a customer's email into every order means updating it in 400 places later.
- 03Pick real types. Numbers as numbers, dates as dates, true/false as booleans. Text for everything breaks sorting and math.
- 04Say what is required. NOT NULL on fields the app cannot work without catches bugs at the door.
- 05Name plainly. created_at, owner_id, is_published: names a stranger could guess.
Schemas when building with Startbase
Startbase Cloud gives a project a managed Postgres database. The agent designs the schema from your description and changes it through SQL migrations; the Database section shows your tables and a table browser, and the Schema Sync panel lists applied and pending migrations (database docs). Who may read which rows is set by row level security policies on the same tables (row level security explained). The most useful thing you can give the agent is the list of things your app tracks and how they relate.
Design the database for a dog-walking app. Owners have many dogs; walkers accept walks; each walk has one walker, one or more dogs, a start time with time zone, a duration in minutes, a price in cents and a status (requested, accepted, done, canceled). Store photos per walk. Owners see only their own dogs and walks; walkers see walks assigned to them.
Common confusions
- Schema vs data. Deleting rows leaves the schema; dropping a column removes it from every row.
- Schema in Postgres. Postgres also uses "schema" for a named folder of tables (public is the default). Same word, narrower meaning.
- Schemaless. Document databases skip a fixed schema, but the app still assumes one; it just is not enforced. For background, read database basics for non-developers and what is Supabase.
Frequently asked questions
Can I change my database schema later?
Yes. Schemas change through migrations: small, ordered scripts that add or alter tables and columns. Adding is easy; renaming or removing columns needs more care with existing data.
What is the difference between a schema and a table?
A table is one collection of rows, such as bookings. The schema is the whole design: every table, its columns, types, rules and relationships.

