Skip to the workspace
Pebellslearn by building
Data Collection  ›  Lesson

Collecting Data from Databases

Databases 12 minDatabases store an organisation's data in related tables, and analysts pull exactly the rows and columns they need with a SQL query.

data analyst / Collecting Data from Databases

Explore each scene at your own pace.

01 · The rule

The rule

Collecting Data from Databases

Kettle & Crumb's till does not save a spreadsheet. Every sale goes straight into a database, alongside the menu and the loyalty list. When Nisha asks for June's cold-coffee sales, the analyst's first job is to get exactly those rows out, reliably, and in a way that can be repeated next month.

The rule

Ask the database for exactly the rows and columns you need.

A relational database stores data in tables that link to each other through keys:

  • orders(order_id, order_date, customer_id, item_code, qty, amount)
  • menu(item_code, item, price)
  • customers(customer_id, name, joined)

orders.item_code points to menu.item_code, so item names are stored once in menu rather than copied into every order. You pull data out with SQL, a language for asking questions of tables:

SELECT order_date, item_code, qty, amount
FROM orders
WHERE item_code = 'C01'
  AND order_date >= '2025-06-01'
  AND order_date <  '2025-07-01';
  • SELECT names the columns you want.
  • FROM names the table.
  • WHERE keeps only the rows that pass every condition.

When you need a name from another table, a JOIN matches rows on their shared key, just as VLOOKUP did on a sheet:

SELECT o.order_date, m.item, o.qty
FROM orders AS o
JOIN menu AS m ON m.item_code = o.item_code;

Analysts normally get read-only access, often to a copy of the live database, so a mistake cannot damage the till's records.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.