1
Step 7 Themes and Keys
Tirsvad edited this page 2026-11-12 01:51:12 +01:00

English · Dansk · Bahasa Malaysia

Step 7: Themes, primary keys and foreign keys

Question: Which theme names belong to the theme ids, and how are the tables linked?

Step 7: Themes, primary keys and foreign keys

What the code does

sets.csv holds theme_id (a foreign key); themes.csv holds the unique id (the primary key) and the theme name. find_theme_ids(themes, "Star Wars") finds four ids (18, 158, 209, 261) and sets_for_theme_ids lists the matching sets, for example the Star Wars Advent Calendars that share one theme.

What you gained

  • A relational database is split into tables linked by keys.
  • A primary key is unique in its own table; a foreign key points to it from another table.
  • One name (Star Wars) can belong to several ids.

Previous: Step-6-Parts-per-Set · Next: Step-8-Merge