Skills / Database basics
Database basics
Give their app real persistence with a hosted database. A free-tier Postgres or SQLite, a schema for their actual data, and full CRUD from their app. Use when localStorage stops being enough, when data must survive across devices or users, or when they ask "how do I store this properly".
Use this skill. Nothing to install.
Don't have an agent? · Raw file: skills/database-basics.md
Watch the first two minutes
This is how a session goes, including the part everyone is afraid of. Click through it.
Scripted example of a real session.
Do I really have to learn SQL?
A little, by hand, and it's the part that pays off longest. The skill has you design the schema on paper around your actual data (two tables maximum, and the second only when a real one-to-many shows up), then type the CREATE TABLE and a few queries yourself in the database console. Client libraries come after, once the layer they wrap is real to you. The finish line is being able to write a SELECT with a WHERE clause unaided. These projects each stand on a schema someone designed this way:
What you end up with
A hosted database with a schema you can explain, and your app doing full CRUD against it. Here is what the workout tracker's database looks like when it's done.
CREATE TABLE workouts ( id serial PRIMARY KEY, day date NOT NULL, exercise text NOT NULL, sets int, reps int, note text );
SELECT day, exercise, sets, reps FROM workouts WHERE day >= '2026-07-01' ORDER BY day;
INSERT INTO workouts (exercise) VALUES ('squats');
ERROR: null value in column "day" violates
not-null constraint
- Every field has a type and a reason. One entry became one row; you said why
dayis a date and why it can't be null. That modeling habit is the durable lesson. - You break it once on purpose. Seeing the NOT NULL error fire teaches what the database refuses on your behalf, before bad data ever gets in.
- Persistence is proven, then localStorage is deleted. Redeploy the app, open it on your phone, the workouts are still there. Then the old storage code goes.
Questions people actually ask
Is SQL hard to learn?
The slice you need here is small: CREATE TABLE, INSERT, SELECT with a WHERE, UPDATE, DELETE. You type each one by hand in the console before app code hides them. Most people are surprised how readable it is.
Is a hosted database free?
Free tiers of hosted Postgres and SQLite cover a personal app comfortably. The skill names the limits before you commit: storage caps, and some free databases pause after inactivity. No card details anywhere.
Where does the connection string go?
It's a secret, so: env vars on the server side, a gitignored .env
locally, never in frontend code, and proven absent from git. If you connect from the
browser via a service like Supabase, the skill explains which key is publishable and
turns on row-level security before any write works.
How many tables should I make?
Two at most, and the second only when a real one-to-many appears in your data (a workout with many sets, an order with many items). Starting with one well-typed table teaches more than a diagram of eight empty ones.
What happens to the data already in localStorage?
You migrate it: read the entries out, INSERT them as rows, check the count matches. Then the localStorage code is deleted from the app so there's exactly one source of truth.
Where to go from here
Shared data raises the next question: whose rows are whose?
Or build something that needs real persistence:
Ideas to use it on
- An alumni and mentors directory that opts in — A directory connecting students at your school with alumni and adult mentors who explicitly opted in: where they work or study, what they'll take questions about, and how they prefer to be reached.
- A membership and dues tracker for a real club — A membership roster and dues ledger for a club you actually belong to.
- The platform your club actually runs on — A management platform for a club you are actually in: member roster, events with RSVP, attendance taken at real meetings, and announcements from officers.
- An inventory system for a family business — A stock-tracking system for a business run by your family or someone you know well: a shop, a stall, a food truck, a workshop.
- The league office for your rec league — A season platform for a rec league you play in or help run: pickup basketball, intramural volleyball, a fantasy league, a chess ladder.
- A newsletter platform with real subscribers — A publishing platform for a newsletter a real group already wants: your neighborhood association's monthly update, your club's weekly recap, the scout troop's announcements.
- A turn-based game two browsers can play — A turn-based game (connect-four, dots-and-boxes, battleship, or a small card duel) that two people play from two different machines.
- An order desk for a real business — An order-request system for a real small business: a family bakery, a neighbor's tailoring shop, a friend's sticker shop.
- QR check-in for a real event — Registration and door check-in for an event you or your group is actually running: a club showcase, a tournament, a fundraiser evening.
- A buy-and-sell board for your school — A listings board for students at your school: textbooks, calculators, uniforms, concert tickets someone can't use.
- A booking system for a tutor or coach — A booking system for one real person who sells their time: a tutor, a music teacher, a sports coach, maybe you.
- A speedrun game with a real leaderboard — One short, skill-heavy level (a platformer sprint, a maze, a precision mouse course, a typing gauntlet) timed to the millisecond, where finishing posts your time to a leaderboard that lives on a server.
- A stats platform your whole team updates — A stats site for a team you play on or manage, where the team itself enters the data.
- A lending library for neighborhood tools — A lending system for physical things your street or building already shares informally: ladders, drills, camping gear, a sewing machine, board games.
- Volunteer hours a real org can verify — An hours platform for an organization you already volunteer with: an NHS chapter, a food bank, a library program, a religious youth group.
Curious? Read the full skill — the exact instructions your agent gets
--- name: database-basics category: code description: Give their app real persistence with a hosted database. A free-tier Postgres or SQLite, a schema for their actual data, and full CRUD from their app. Use when localStorage stops being enough, when data must survive across devices or users, or when they ask "how do I store this properly". --- # database-basics Move someone's app from localStorage to a real database: a hosted free-tier database with a schema designed around their actual data, and their app reading and writing it. The durable lesson is modeling. Tables, rows, and types that match the thing they are tracking. ## Ground rules - Use their real data. The best schema exercise is the app they already built (build-web-app leaves exactly this). If they have no app, pick one small enough that the whole loop still fits in a session. - Compare the current official plans for a hosted Postgres or SQLite service, or use SQLite on a server they already control. Record storage, inactivity, export, and backup limits before committing. No card details anywhere. - Their account, their connection string. Database URLs and service keys are secrets: env vars on the server side, gitignored `.env` locally, never in frontend code. If they use Supabase from the browser, explain which key is publishable and which must never ship, and turn on row-level security before any write works. - Design the schema on paper first. One entry becomes one row; every field gets a type; you both say why. Two tables maximum, and only add the second when a real one-to-many appears in their data. - SQL is not optional. Even behind a client library, they type at least the CREATE TABLE and a few SELECTs by hand in the database console, so they can inspect the layer underneath the client library. ## The path 1. Model out loud: what is one entry, what are its fields, what type is each, what makes a row unique. Write the CREATE TABLE together and run it in the provider's SQL console. 2. Seed and query by hand: INSERT three rows, SELECT them back, UPDATE one, DELETE one, all in the console. Now the database is real before any app code touches it. 3. Connect from their code with the connection string in an env var. First read: the app lists rows from the database instead of localStorage. 4. Complete the loop: create, update, delete from the app. Bad input rejected before it reaches the database, and a NOT NULL or type error triggered once on purpose so they see the database defend itself. 5. Prove persistence: redeploy the app, open it on their phone, data still there. Delete localStorage use from the code. 6. README note in their words: what the schema is and where the connection string lives for anyone cloning. 7. Export a small backup or schema dump and document how it would be restored. ## Done - A hosted database with a schema they designed and can explain - Their app doing full CRUD against it; localStorage retired - Data survives redeploys and shows up across devices - Connection string and keys in env vars only, proven absent from git - A tested export path and restore note, so the provider is not the only copy - They can write a SELECT with a WHERE clause unaided Then: auth-basics, since data shared by everyone raises the question of who is allowed to see and change which rows.







