← All sections

Section 4

Where the information goes

Databases, from a single file on your laptop up to a paid service that runs the whole back end for you — and which one to actually start with.

New to all this? If you've never typed a command into a black window before, read Section 0 first. It covers opening the Terminal, running a command, and telling whether it worked. This page has fewer commands than the others — it's mostly about choosing well.

What a database actually is

You already understand a database. It's a spreadsheet.

Rows going across, columns going down, one sheet per kind of thing. A sheet of songs. A sheet of people. A sheet of orders.

idtitleartistrating
1NobodyMitski5
2Francis ForeverMitski4
3Motion SicknessPhoebe Bridgers5

That's a database table. Genuinely. The vocabulary is fancier but the shape is exactly what you'd expect.

So why not just use a spreadsheet? Two reasons, and they're the only two that matter:

Do you even need one?

Ask this before you build anything. The honest answer is usually no, and saying no saves you a great deal of work.

The test Does anything need to still be there after the visitor closes the tab?

No → you don't need a database.
Yes → you do.
What you're buildingDatabase?
Portfolio, blog, band page, anything you write yourselfNo. Just files.
A contact form that emails youNo. The email is the record.
People log in and have their own stuffYes
Visitors post, comment, or uploadYes
Anything with orders, bookings, or paymentsYes
A searchable list that changes oftenProbably

The site you're reading has no database. It's plain files on a server. That's why it never goes down, costs nothing to run, and has nothing to back up.

Five options, honestly compared

NameWhat it isCostGood for
SQLite One file on your computer. No server, nothing running. Free Learning, and honestly most small projects
PostgreSQL A proper database server. Free, open, the modern default. Free — you run it Real apps, anything that will grow
MySQL The older standard. Runs a huge share of the web, including WordPress. Free — you run it Joining a project that already uses it
Supabase Postgres that someone else runs, plus logins, file storage and a dashboard. Free tier, then paid Getting a real app with accounts working fast
Firebase Google's. A different shape — not tables, more like nested folders. Free tier, then paid Chat and live-updating apps

In plain terms

SQLite is a file called something like mystuff.db sitting in your project folder. You can copy it, email it, back it up by duplicating it. There's no server, nothing to start, nothing to pay for, nothing to break. People assume it's the toy option — it isn't. It's in every phone in your pocket and it runs plenty of real websites.

Postgres is what SQLite grows into. An actual program running in the background, built for many people at once. It's free and it's what most serious new projects choose. Slightly more to set up — which your AI can do for you.

MySQL does roughly the same job and got there first. Nothing wrong with it. But if you're choosing fresh today, Postgres is the more capable of the two and the one you'll see more of in new work. Learn MySQL when a project hands it to you, not by choice.

Supabase is Postgres with the boring parts done for you. Same database underneath, but you don't run the server — and it hands you user accounts, password resets, file uploads and a web dashboard to click around in. This matters more than it sounds: building login properly is genuinely hard and very easy to get dangerously wrong.

Firebase is the odd one out. It doesn't use tables or SQL — it stores things more like nested folders. Brilliant for chat apps and anything that updates live on everyone's screen at once. But what you learn there doesn't transfer to the others, so it's not where to begin.

What to start with

Start with SQLite. Move to Supabase when you need accounts. That's the whole recommendation.

Why SQLite first:

Then move to Supabase when people need to log in, or several people share data, or it needs to be online rather than on your laptop.

The jump is gentler than you'd expect, because Supabase is Postgres — the same SQL you already wrote keeps working. You're changing where the database lives, not how you talk to it.

Why not just start with Supabase? You can, and it's a reasonable choice. But you'd be learning a database and accounts and a dashboard and hosting all at once, and when something breaks you won't know which of the four to blame. A week with SQLite first means you already know what's normal.

The four words of SQL

SQL is how you talk to almost all of these. People find it intimidating for about ten minutes, until they notice it's nearly English.

There are four words that cover the overwhelming majority of what you'll ever do:

WordMeans
SELECTshow me
INSERTadd a new one
UPDATEchange an existing one
DELETEremove one

Using that songs table from earlier:

-- show me everything
SELECT * FROM songs;

-- show me only the Mitski ones
SELECT * FROM songs WHERE artist = 'Mitski';

-- show me my favourites, best first
SELECT title, artist FROM songs
WHERE rating = 5
ORDER BY title;

-- add one
INSERT INTO songs (title, artist, rating)
VALUES ('Washing Machine Heart', 'Mitski', 5);

-- change one
UPDATE songs SET rating = 4 WHERE title = 'Nobody';

-- remove one
DELETE FROM songs WHERE title = 'Nobody';

Read those out loud. Select everything from songs where artist is Mitski. It's a sentence. That's the whole trick — SQL was deliberately designed to read like English, back when people hoped managers would write it themselves.

WHERE is the word doing the real work. It means "only the ones that match". Which brings us to the dangerous part.

The scariest thing in this section

Leaving off WHERE hits every single row DELETE FROM songs; doesn't delete a song. It deletes all of them. Instantly, with no confirmation and no undo.

UPDATE songs SET rating = 1; sets every song in the table to one star.

This is the rm -rf of databases, and it has taken down real companies. It's usually someone tired, working on the live database, who ran the first half of a line before finishing the second half.

Two habits that make you basically immune:

Habit 1 — write the WHERE first Type WHERE title = 'Nobody' before you type the DELETE in front of it. Then a half-finished line can't do any damage.
Habit 2 — SELECT before you DELETE Run it as a SELECT with the exact same WHERE, and look at what comes back. Those are the rows you're about to destroy. If it's 4,000 rows and you expected one, you just saved yourself.
-- first, look
SELECT * FROM songs WHERE artist = 'Mitski';
-- 4 rows. That's what I expected.

-- now, delete
DELETE FROM songs WHERE artist = 'Mitski';

Ten extra seconds. Do it every time and it becomes automatic.

Keeping it safe

Never store passwords as text

If your table has a column with passwords readable in it, and that database ever leaks, you've handed away every one of those accounts — and because people reuse passwords, probably their email too.

Real systems store a scrambled version that can be checked against but not reversed. Doing this correctly is fiddly and easy to get subtly wrong.

So don't build login yourself Use Supabase's built-in accounts, or a similar service. This isn't about being a beginner — experienced developers use these too, precisely because the cost of a mistake is other people's lives getting harder.

Never put the database password in your code

It goes in a .env file that stays on your computer. Your code reads it from there. Ship a .env.example listing only the names — Section 3 covers this.

Never paste what a user typed straight into SQL

If someone can type into a box and have their words become part of your SQL, they can write their own commands — including DELETE. It's called SQL injection and it's the oldest trick there is.

The fix is to pass values separately instead of gluing them into the text:

-- Dangerous: their text becomes part of the command
"SELECT * FROM songs WHERE artist = '" + whatTheyTyped + "'"

-- Safe: the value is handed over separately
"SELECT * FROM songs WHERE artist = ?", [whatTheyTyped]

That ? is the whole defence. Every database library supports it. Add this line to your AGENTS.md and it stops being something you have to remember:

Never build SQL by joining strings together. Always use
parameters (?) so user input can't become part of the command.

Back it up

With SQLite, a backup is copying the file:

cp mystuff.db mystuff-backup-2026-09-21.db

With Supabase, backups happen for you — worth checking which plan you're on and how far back they go, before you need them.

Things to try

  1. Make a database about something you actually care about. Your music, books, films, plants. Ask your AI: "help me make a SQLite database of my favourite albums, with columns I'd actually want." Deciding the columns is the real exercise.
  2. Ask it questions. Everything from 2019. Everything rated 5. Everything by one artist, alphabetically. This is where SQL clicks.
  3. Practise the safety habit. Before every DELETE, run the SELECT first. Do it ten times and it's permanent.
  4. Design a table for an idea you don't have yet. "If I built an app for tracking who borrowed my books, what tables would I need?" Sketching the shape before building is most of the skill.
  5. Look at Supabase's free tier. Don't build anything. Just make an account, click around the dashboard, and see that it's the same rows and columns you've been working with all along.