Setting up your first database
Installing a real database on your machine, connecting to it, and running your very first commands - the practical, hands-on lesson.
Why this lesson exists before "real" SQL
Every lesson so far has been concepts and theory. Before Module 2 throws real SQL syntax at you, you need somewhere to actually run it. This lesson is entirely practical: get a real database running (in your browser, on your machine, or in the cloud), and confirm you can create a table and query it. Everything after this point in the course assumes you have a working database in front of you.
SQL code blocks in this course are for reading and copying; they do not execute on this page. You run them in a database of your own, and you have three realistic options, ranked from "zero setup" to "closest to a real production server." Pick whichever matches your patience level right now — you can always switch later.
Option 1: no install at all (online SQL playgrounds)
Several free websites give you a real database engine in a browser tab — no install, and for most of them no account. This is the fastest way to follow along with every lesson: copy a code block from here, paste it into the playground, and run it.
- SQLite Online — a full SQL editor in the browser that supports SQLite, PostgreSQL, MySQL, and more from a single page. Pick the engine in the left sidebar, paste your SQL, and press Run.
- DB Fiddle — choose MySQL, PostgreSQL, or SQLite, put the schema (
CREATE TABLEandINSERT) on the left and yourSELECTon the right, and run. It also generates a shareable link, which is handy for asking questions or showing someone your query. - OneCompiler — a simple online editor with separate pages for PostgreSQL, MySQL, SQLite, and others. Good when you just want to paste a script and see the output.
- W3Schools Tryit SQL editor — comes with a pre-loaded sample database (customers, orders, products), so you can practise
SELECTqueries immediately without creating any tables. - PGlite REPL — runs a real PostgreSQL entirely inside your browser, useful when you specifically want Postgres behaviour with zero setup.
Try this in any of them. It works on SQLite, PostgreSQL, and MySQL:
CREATE TABLE greeting (message VARCHAR(50));
INSERT INTO greeting VALUES ('Hello, database!');
SELECT * FROM greeting;
Playgrounds are great for learning and quick experiments, but most reset when you close the tab (copy your script somewhere if you want to keep it), and the engine may differ from the one you use later. A few features, such as user management or multi-connection concurrency demos, cannot be shown properly in a single-tab playground. For those, use one of the options below.
Option 2: install PostgreSQL locally
PostgreSQL (usually just "Postgres") is the database this course leans on most for real examples, because it's free, open-source, closely follows the SQL standard, and is genuinely used at massive scale in production (Instagram, Spotify, and thousands of others run on it). Module 6 covers it in depth; for now, just get it installed.
Windows:
- Download the installer from
postgresql.org/download/windowsand run it. - During setup, you'll be asked to set a password for the default
postgressuperuser — remember it. - Keep the default port,
5432. - The installer includes pgAdmin, a graphical tool for browsing databases — useful, but you can also just use the command line.
macOS (via Homebrew):
brew install postgresql@16
brew services start postgresql@16
Linux (Debian/Ubuntu):
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
Connecting and running your first command, once installed:
# Open a SQL shell (psql is Postgres's command-line client)
psql -U postgres
# Inside psql, create a database and switch to it
CREATE DATABASE placeprep_learn;
\c placeprep_learn
# Create a table and query it
CREATE TABLE greeting (message TEXT);
INSERT INTO greeting VALUES ('Hello from real Postgres!');
SELECT * FROM greeting;
\c is a psql-specific shortcut (not standard SQL) for switching the database you're connected to. Commands starting with \ are always client shortcuts, never sent to the server as SQL.
Option 3: a free cloud database (zero local install, closest to real jobs)
In real companies, you rarely install a database on your own laptop for production use — you provision one from a cloud provider. Several offer a genuinely free tier, which is worth trying at least once in this course since Module 6 discusses cloud vs. self-hosted trade-offs in detail:
- Neon — serverless PostgreSQL, generous free tier, gives you a connection string in under a minute.
- Supabase — PostgreSQL plus a full backend platform (auth, storage, auto-generated APIs) built on top, also has a free tier.
- Railway / Render — general cloud hosting with one-click Postgres/MySQL instances.
The workflow is always the same shape: sign up, click "create database," and you're handed a connection string — a single URL encoding everything needed to connect:
postgresql://username:password@host:5432/database_name
psql, pgAdmin, DBeaver, or directly into application code (Node.js, Python, etc.) using a database driver library.
A universal client: DBeaver
Regardless of which database you choose, DBeaver is a free, open-source graphical client that connects to PostgreSQL, MySQL, SQLite, and dozens of others through one consistent interface — a table browser, a query editor, and visual schema diagrams. It's a genuinely useful tool to have installed for the rest of this course and for real work afterward, since you won't need a different tool for every database engine you touch.
Confirming everything works
Whichever path you chose, run this exact sequence and confirm you see the row come back — this is the checkpoint for the rest of the course:
CREATE TABLE setup_check (
id INTEGER PRIMARY KEY,
status TEXT
);
INSERT INTO setup_check (id, status) VALUES (1, 'Database is working!');
SELECT * FROM setup_check;
Database is working!, you're fully set up. Module 2 starts writing real SQL against a real, evolving dataset.
Common mistakes
- Forgetting the password set during Postgres install. There's no "forgot password" flow for a local database — you either remember it, reset it via the OS-level config file, or reinstall. Write it down somewhere safe the moment you set it.
- Connecting to the wrong database. A single Postgres server can host many separate databases (like
placeprep_learnabove). Creating a table in one doesn't make it visible from another — always double check which database your client is currently pointed at. - Using a cloud free tier for a real production app without reading the limits. Free tiers usually cap storage, connection count, or auto-pause after inactivity — great for learning, risky to build a real business on without a paid plan later.
Summary
You now have a genuinely working database — whether that's an online playground, a locally installed PostgreSQL server, or a free cloud instance. Every SQL statement from here on is something you can (and should) actually run yourself, not just read. Module 2 begins with SQL properly: creating tables with real constraints, and the four core operations — Create, Read, Update, Delete — that every application ever built performs against its database.