Designing a schemaProLesson 31 of 45, about 9 min
- 1
- 2
- 3
- 4
- 5
- 6
- 7
The app: Ledger, a database client
Ledgerharbor · stagingharbor_dev
public
idteamplanplan_pricestatus
1Northwind Studiopro29.00active
2Kestrel Labsbusiness79.00active
3Bramble & Copro29.00active
4Otter Analyticsstarter9.00active
5Juniper Healthpro24.00active
6Pine Street Bookspro29.00canceled
6 rows. The price of each plan is typed into every row that uses it.
The schema as SQL, and what the database answers
subscriptions the table your agent wrote1 table
create table subscriptions (
id bigserial primary key,
team text,
owner_email text,
plan text,
plan_price numeric, -- a copy in every row
status text
);
Pro’s price one copy per row4 copies
select team, plan_price from subscriptions where plan = 'pro';
Northwind Studio
Bramble & Co
Juniper Health
Pine Street Books
The MagisterLeft: Ledger, open on Harbor’s billing database. Your agent put everything in one subscriptions table, so each row carries a copy of its plan’s price. Pro costs $29.00, yet one row says $24.00: when the price changed, one copy was missed. Tap the price that disagrees.
Step 1 of 7Find the price that disagrees
- Tap the Pro price that disagrees
You’re not signed in, so this lesson won’t be saved to your path. Sign in free to keep your XP.