DataBrighten

    Sample SQL database

    4 tables1,782 order items, 1,000 orders, 300 customers, 56 products

    Updated 3 November 2026. Fictional U.S. businesses and people, generated with a fixed seed.

    textnumberdateyes/no
    Rows3,138across 4 tables
    Columns24with a data dictionary below
    Dates2024-01-01 – 2024-12-29range in the file
    LicenceCC0synthetic, free for any use

    What is in it

    A small online-store database in one .sql file that loads into PostgreSQL, MySQL or SQLite, with primary and foreign keys: 300 customers, 56 products, 1,000 orders and their order items. CSV and Excel copies of each table are included.

    First rows

    orders table

    order_idnumbercustomer_idtextorder_datedatestatustextship_statetext
    1CU102442024-09-17DeliveredNY
    2CU100262024-06-20DeliveredNC
    3CU100862024-11-24DeliveredNY
    4CU101952024-08-31DeliveredCO
    5CU101302024-09-16DeliveredTX
    6CU101662024-11-21ReturnedNJ
    7CU100992024-09-30DeliveredCT
    8CU100372024-10-01DeliveredIN

    Data dictionary

    customers 300 rows

    ColumnTypeMeaning
    customer_idtextCustomer number
    first_nametextFictional first name
    last_nametextFictional last name
    emailtextexample.com address
    citytextCity
    statetextState code
    signup_datedateAccount created
    segmenttextConsumer, Small Business or Enterprise

    products 56 rows

    ColumnTypeMeaning
    product_idtextProduct number
    categorytextCategory
    sub_categorytextSub-category
    product_nametextGeneric product name
    unit_pricedecimalList price (USD)
    unit_costdecimalCost (USD)

    orders 1,000 rows

    ColumnTypeMeaning
    order_idintegerOrder number
    customer_idtextFK to customers.customer_id
    order_datedateOrder date (2024)
    statustextDelivered, Shipped, Processing, Cancelled or Returned
    ship_statetextState shipped to

    order_items 1,782 rows

    ColumnTypeMeaning
    item_idintegerLine number
    order_idintegerFK to orders.order_id
    product_idtextFK to products.product_id
    quantityintegerUnits
    unit_pricedecimalPrice charged per unit (USD), after any discount

    Practice questions

    answers checked in SQL and in Python

    Revenue by product category, excluding cancelled and returned orders?

    Technology $537,612.64; Furniture $200,325.49; Office Supplies $67,416.80

    SQL

    SELECT p.category, ROUND(SUM(i.quantity*i.unit_price),2) AS revenue
    FROM order_items i
    JOIN orders o ON o.order_id = i.order_id
    JOIN products p ON p.product_id = i.product_id
    WHERE o.status NOT IN ('Cancelled','Returned')
    GROUP BY p.category
    ORDER BY revenue DESC

    File: store-database

    Top 5 customers by revenue (excluding cancelled and returned orders)?

    Steven Lewis (CU10118) $21,983.66; Patricia Khan (CU10105) $15,506.69; Elizabeth Flores (CU10237) $14,375.98; Mei Nelson (CU10039) $14,273.55; Carol Clark (CU10292) $14,080.03

    SQL

    SELECT c.customer_id, c.first_name || ' ' || c.last_name AS name, ROUND(SUM(i.quantity*i.unit_price),2) AS revenue
    FROM customers c
    JOIN orders o ON o.customer_id = c.customer_id
    JOIN order_items i ON i.order_id = o.order_id
    WHERE o.status NOT IN ('Cancelled','Returned')
    GROUP BY c.customer_id, name
    ORDER BY revenue DESC
    LIMIT 5

    File: store-database

    How many customers have never placed an order?

    8 customers

    SQL

    SELECT COUNT(*)
    FROM customers c
    LEFT JOIN orders o ON o.customer_id = c.customer_id
    WHERE o.order_id IS NULL

    File: store-database

    Orders by status?

    Delivered 804; Shipped 66; Cancelled 51; Processing 47; Returned 32

    SQL

    SELECT status, COUNT(*) FROM orders GROUP BY status ORDER BY COUNT(*) DESC

    File: store-database

    What is the list price of product P0012?

    Corner Bookcase, $188.81

    Excel

    =XLOOKUP("P0012",A:A,E:E), or =VLOOKUP("P0012",A:F,5,FALSE), on the products sheet

    SQL

    SELECT product_name, unit_price FROM products WHERE product_id = 'P0012'

    File: store-database