How to Create Your First Database Table
Column types, defaults, required fields and relationships — designed so you are not migrating data in three weeks.
Written and reviewed by Lovable Student — Independent guides, prompts and troubleshooting notes for people building with Lovable. Expert build help provided by PromptSites.com.
Published 24 Aug 2026 · Tested with Lovable as of 24 Aug 2026

Overview
A table is a spreadsheet with rules. The rules — types, defaults, required fields, relationships — are what stop bad data getting in.
Beginner explanation: Decide what one row represents before you create anything. "One row is one booking" is a complete design decision.
Technical explanation: Prefer explicit types and NOT NULL with sensible defaults. Add a foreign key to the owning user for anything user-specific, and index the columns you will filter on.
Steps
- Write down what one row represents.
- List every field and its type.
- Decide which fields are required and what the defaults are.
- Decide who owns the row — usually a user reference.
- Ask for the table and its access rules in one prompt.
:::tip Timestamps are free and always useful. Include a created date on every table. :::
What to check afterwards
- Inserting a row from the app succeeds
- Required fields reject empty values
- Rows are linked to the right owner
Common problems
- Everything stored as text. Dates and numbers should be dates and numbers.
- No owner column. You cannot write per-user access rules later.
- Nullable everything. Broken rows appear months later.
Where people get stuck
If you have followed the steps and the result still is not right, the fastest path is usually to describe the exact behaviour you expected, the behaviour you got, and any error text, then ask for a fix in one focused follow-up prompt. If that loop is not converging, hand it over.
Was this guide helpful?
Next step
You might also need
- PromptCreate a Database Table With Access RulesCreates a table and its security policies in one step, so you never end up with a table nobody can query.
- AnswerHow do I back up my Lovable database?Lovable Cloud stores backups you can restore from directly in the Database screen; for extra safety, also ask Lovable to export your data periodically.
- AnswerHow do I connect Supabase to Lovable?In your Lovable project, open the Supabase integration and authorise Lovable to connect to an existing Supabase project (or create a new one), then Lovable can read and write to it the same way it does with Lovable Cloud.
- AnswerHow do I safely store API keys?Store keys as secrets in your backend (Lovable Cloud/Supabase) and call the third-party API from a server/edge function — never put keys in front-end code.