StoicBuilder

HandbookII the ForumDatabases and tables

IIthe Forum, The shape of an app

Databases and tables

1 min readUpdated 28 November

In plain words

A database stores your app's data so it survives refreshes and restarts, organised into tables where each row is one thing and each column one detail.

Where you see it

The Table Editor in Supabase, which looks like a spreadsheet: Chirp's posts table with columns for id, author_id, content, likes and created_at. Every post anyone writes becomes one new row.

Supabase SQL Editordatabase
create table posts ( id bigint generated always as identity primary key, author_id uuid not null references auth.users (id), content text not null, likes integer not null default 0, created_at timestamptz not null default now());
Every column has a type. not null means a row can't be saved without that value.

What goes wrong

  1. Money and dates stored as text

    Text sorts character by character, so "100" comes before "9" and dates can't be compared properly. Store prices as numeric or whole cents, and times as timestamptz.

  2. A list squeezed into one column

    Tags saved as "vegan, cheap, late-night" in a single text column are hard to search or count. A list of things usually wants its own table.

  3. Switching off access rules to make an error go away

    When Supabase returns empty results, agents sometimes switch off row-level security, Supabase's per-row access rules, to "fix" it. That opens the table to anyone holding your public key.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Show me every table in my database with its columns, their types and what each one is for, in plain English. Flag any column that stores a list as text, money as a floating-point number, or dates as text.

Quick check

Sign in to earn +10 XP for it

Sorting QuickBite orders by total, lowest first, gives 100, 12, 9.5. What's going on?

Got a prompt that touches databases and tables?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.