The Demo Database

Every example in this course uses the same small database for an imaginary online shop. Knowing its tables and how they connect will make the rest of the course much easier to follow — come back to this page whenever you need a reminder.

The tables

TableRowsWhat it holds
customers10People who have signed up to the shop
products12Items for sale, with category, price and stock
orders15One row per order: who placed it, when, and its status
order_items23The products in each order, with quantity and price paid
employees12Staff, with salary, department and manager
departments5The company's departments and where they're based

How the tables connect

TXT relationships
customers 1 ──< orders 1 ──< order_items >── 1 products

departments 1 ──< employees
employees (manager) 1 ──< employees
  • A customer can place many orders; each order belongs to one customer (orders.customer_id).
  • An order contains many order items; each item refers to one product (order_items.order_id, order_items.product_id).
  • A department has many employees (employees.department_id).
  • An employee's manager is another employee (employees.manager_id).

customers

SQL
SELECT * FROM customers;
Result 10 rows
idnameemailcitycountrysignup_date
1Ana Pereiraana.pereira@example.comLisbonPortugal2024-02-11
2Ben Carterben.carter@example.comManchesterUK2024-05-23
3Chloé Martinchloe.martin@example.comLyonFrance2024-07-02
4David Müllerdavid.mueller@example.comBerlinGermany2024-09-15
5Elena Garcíaelena.garcia@example.comMadridSpain2025-01-08
6Farah Haddadfarah.haddad@example.comNULLFrance2025-03-19
7George Browngeorge.brown@example.comLondonUK2025-06-30
8Hana Novakhana.novak@example.comPragueCzechia2025-08-21
9Isaac Leviisaac.levi@example.comPortoPortugal2025-11-04
10Julia SantosNULLLisbonPortugal2026-01-14

Notice the gaps: Farah has no city and Julia has no email. Missing values are stored as NULL (lesson 11).

products

SQL
SELECT * FROM products;
Result 12 rows
idnamecategorypricestock
1The Patient GardenerBooks24.940
2Learning SQL Step by StepBooks32.525
3Night Sky AtlasBooks458
4Wireless EarbudsElectronics59.9960
5USB-C ChargerElectronics19.99120
6Mechanical KeyboardElectronics890
7Ceramic MugHome12.5200
8Desk LampHome3415
9Linen ThrowHome4930
10Jigsaw Puzzle 1000Toys1850
11Wooden Train SetToys39.912
12Smart PlugElectronics14.9975

orders

SQL
SELECT * FROM orders;
Result 15 rows
idcustomer_idorder_datestatus
112025-09-03delivered
222025-09-14delivered
312025-10-01delivered
432025-10-20delivered
542025-11-02cancelled
652025-11-15delivered
722025-12-01delivered
872025-12-12delivered
962026-01-07shipped
1082026-01-22delivered
1112026-02-03shipped
1292026-02-14pending
1332026-02-20pending
1442026-03-01delivered
1572026-03-05pending

An order's status is one of pending, shipped, delivered or cancelled.

order_items

SQL
SELECT * FROM order_items LIMIT 6;
Result 6 rows
order_idproduct_idquantityunit_price
11124.9
17212.5
24159.99
32132.5
35219.99
49149

The unit_price is copied from the product when the order is placed, so later price changes don't rewrite history. This table has a composite primary key: the pair (order_id, product_id).

employees and departments

SQL
SELECT id, first_name, last_name, department_id, job_title, salary, manager_id
FROM employees;
Result 12 rows
idfirst_namelast_namedepartment_idjob_titlesalarymanager_id
1OliviaBrandtNULLChief Executive150000NULL
2RafaelCosta1Sales Manager820001
3MeiTanaka2Engineering Manager980001
4JonasWeber2Senior Developer850003
5AmaraOkafor2Developer680003
6LucasFerreira1Sales Representative520002
7SofiaRossi1Sales Representative540002
8DanielKim3Marketing Lead710001
9HannahSchmidt3Content Writer480008
10EthanWalsh4Support Lead600001
11PriyaNair4Support Agent4200010
12TomásSilva2Developer680003
SQL
SELECT * FROM departments;
Result 5 rows
idnamelocation
1SalesLisbon
2EngineeringBerlin
3MarketingLisbon
4SupportDublin
5ResearchNULL

The chief executive has no department and no manager, and the Research department has no employees yet — details that matter when we reach joins.

The table definitions

This is how the orders table was created. You'll learn to write statements like this in lessons 40–43.

SQL
CREATE TABLE orders (
  id INTEGER PRIMARY KEY,
  customer_id INTEGER NOT NULL REFERENCES customers(id),
  order_date DATE NOT NULL,
  status TEXT NOT NULL CHECK (status IN ('pending', 'shipped', 'delivered', 'cancelled'))
);

Exploring the schema yourself

Every database stores a description of its own tables. In SQLite, it's the sqlite_schema table; most other systems use the standard information_schema views (lesson 52).

Try it yourself
Result