In plain words
Designing a schema means deciding which tables exist, what each row stands for, how tables link through keys, and which rules the database itself enforces, so bad data can't get in even when the code has bugs.
Where you see it
Harbor needs teams, members, plans, subscriptions and invoices. Each becomes a table with a primary key, each invoice points to its team with a foreign key, and constraints refuse an invoice with a negative amount or a second active subscription for the same team.
What goes wrong
- Storing money as a floating-point number
In floating point, 0.1 + 0.2 is 0.30000000000000004, and invoice totals drift by a cent. Store whole cents in an integer column, or use numeric, and keep the currency beside it.
total float - Rules that live only in the app code
If only the TypeScript checks that a team has one active subscription, a second code path, a script or two simultaneous requests will break the rule. Put it in the database as a constraint or unique index.
create unique index one_active_sub on subscriptions (team_id) where status = 'active'; - One wide table for everything
A users table with plan_name, plan_price, team_name and invoice_1_total columns gets harder to change with every feature. Give each kind of thing its own table and link them with keys.
What to tell your agent
Quick check
Sign in to earn +10 XP for itA Harbor team must never have two active subscriptions. Where is the safest place to enforce that?