Set Up a Database and Load Sample Data
Part of the SQL Roadmap
In short
Reading about SQL only gets you so far. In this project you install a real database, create tables and load a sample shop dataset, so every topic after this runs on real rows.
Install MySQL or PostgreSQL, create a practice database and load a realistic sample dataset so every later topic can be practised on real tables instead of toy examples.

Think of it like this
Setting up a new kitchen
Before you cook your first meal in a new flat, you install the stove, put up shelves and stock the rasoi with dal, rice and masalas. Installing the database is the stove, CREATE TABLE is the shelves, and loading CSV files is filling them with groceries.
Watch it happen
From empty laptop to queryable data
1/5Install PostgreSQL (or MySQL) and a client like DBeaver or pgAdmin.
The big ideas
What you need to know
Use a separate practice database
A dedicated shop database means you can drop and rebuild it freely while learning.
Parents before children
Create and load customers before orders, because orders points to customers through a foreign key.
Bulk load, don't type
COPY in PostgreSQL and LOAD DATA in MySQL read a whole CSV file in seconds.
Always verify
Compare row counts with the CSV and check a few rows by eye. Silent date or encoding mix-ups are common.
How it works
Project steps
- 1
Install
PostgreSQL from postgresql.org, or MySQL Community Server, plus a client.
- 2
Create the database
Run CREATE DATABASE shop; then connect to it.
- 3
Create tables
customers first, then orders with a foreign key.
- 4
Load and check
Load the CSVs, then count rows and run a sample query.
See it in code
Walk through the code
1CREATE DATABASE shop; -- then connect to shop in your client2 3CREATE TABLE customers (4 customer_id INTEGER PRIMARY KEY,5 name TEXT NOT NULL,6 city TEXT7);8 9CREATE TABLE orders (10 order_id INTEGER PRIMARY KEY,11 customer_id INTEGER REFERENCES customers (customer_id),12 order_date DATE,13 amount NUMERIC(10, 2)14);15 16COPY customers FROM '/data/customers.csv' WITH (FORMAT csv, HEADER true);17COPY orders FROM '/data/orders.csv' WITH (FORMAT csv, HEADER true);18 19SELECT COUNT(*) FROM orders;20SELECT * FROM orders ORDER BY order_date DESC LIMIT 5;1/5A fresh database for practice. Switch your client's connection to it.
PostgreSQL setup. COPY reads files on the server; from psql on your own laptop use \copy with the same options. In MySQL, use LOAD DATA LOCAL INFILE '/data/orders.csv' INTO TABLE orders FIELDS TERMINATED BY ',' IGNORE 1 LINES;
Save yourself the pain
Common mistakes
Oops
Loading orders before customers and getting foreign key errors.
Do this instead
Load parent tables first. Every customer_id in orders must already exist in customers.
Oops
Forgetting HEADER and getting an error because 'order_id' isn't a number.
Do this instead
Tell the loader the file has a header row, or remove that line from the CSV.
Oops
Practising in a database that holds real data.
Do this instead
Always learn in a throwaway database you can drop and rebuild.
Your mission
Build your practice shop
Quick check
Why should you load customers before orders?
Go deeper
- 1Install the database and a client, then create a new database called practice.
- 2Load a sample database such as Sakila, Pagila or a public e-commerce dataset, or import a CSV file into a new table.
- 3Write down every table, what one row means and how the tables connect, as your first schema map.
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.