4 MIN · 2026-08-04

A tour of the record store database

Meet the tables behind every SQLazo exercise: artists, albums, tracks, customers and the invoices that tie them together.

A tour of the record store database

Every SQLazo exercise runs against the same little world: a record store with ten tables. Before you write your first query, it helps to meet the neighborhood. This is the map.

The catalog chain: artists → albums → tracks

The heart of the store is a chain of three tables.

  • artists — 12 bands, with name, country and formed_year
  • albums — 17 albums; each row says which artist it belongs to (artist_id)
  • tracks — 49 songs; each row says which album (album_id) and which genre it belongs to

Let's walk it. The Swedish artist Astrid Lindqvist is artist_id 4, so her albums come from a simple question:

SELECT title, release_year
FROM albums
WHERE artist_id = 4;

Two albums: Fjord Songs (2009) and Winter Light (2014).

One level down, the tracks on an album:

SELECT title, duration_sec
FROM tracks
WHERE album_id = 1;

Golden Hour (the album) holds three songs: Golden Hour (245 seconds), Paper Sun (198) and Slow Parade (267). Notice the store thinks in seconds — nobody does, which is why the numbers chapter exists.

The people: customers and employees

Fifteen customers across twelve countries, each with an email, a city and a joined_date. Every customer points at a support rep (support_rep_id) — an employee. There are seven employees, and they have their own chain of command: each one's boss is stored as reports_to. Jane Foster runs the store and reports to nobody — her reports_to is NULL.

Money: invoices and invoice_lines

Money doesn't flow in one blob. Every purchase is an invoice, and every invoice is built from lines. invoices holds 22 invoices: who bought (customer_id), when (invoice_date), where it was billed, and the total. invoice_lines breaks each invoice into one row per song sold — 40 lines across the whole store.

Daniel Brooks (customer 1) has two invoices:

SELECT id, invoice_date, billing_city, total
FROM invoices
WHERE customer_id = 1;

Invoice 1 (2022-01-15, Austin, 2.58) and invoice 9 (2022-11-11, Austin, 3.27).

And here's what one Madrid customer walked out with on invoice 2:

SELECT il.quantity, t.title
FROM invoice_lines il
JOIN tracks t ON il.track_id = t.id
WHERE il.invoice_id = 2;

Two copies of Mar Adentro, one Corazón de Sal, one La Marea. That join — from invoice_lines to tracks — is a preview: the joins chapter teaches you to walk these chains properly.

Two more tables, and the quirks

  • genres — the eight genre names behind all those genre_ids.
  • featured_2023 and featured_2024 — the store's playlist picks for those years.

And the quirks. The data is hand-written with intentional roughness, so the later chapters have something real to practice on:

  • NULLs. Nocturne Quartet and The Paper Cranes never reported a founding year — their formed_year is NULL. The live album Crossroads Live has no release year, and two customers have no support rep.
  • Messy strings. One track is called ' solstice ' — with stray spaces on both sides — and another is 'midnight train' in lowercase. They exist so the pattern-matching chapter has something to hunt:
SELECT title FROM tracks WHERE title LIKE '%solstice%';
SELECT title FROM tracks WHERE title LIKE '%train%';

Keep exploring

Start with the first-queries chapter: four minutes of reading and seven small exercises — the simplest way to start asking these tables questions.

Keep learning