Beginner level · Module 3 of 5 · 10 guided hours
Keys, Relationships and Joins
Connect tables with primary and foreign keys and combine their data with inner and left joins.
Learning objectives
- Define primary and foreign keys
- Combine related tables with INNER JOIN
- Use LEFT JOIN to keep unmatched rows and find missing data
Topics
- primary keys
- foreign keys and referential integrity
- one-to-many relationships
- INNER JOIN
- LEFT JOIN
- table aliases
Lessons
-
Lesson 1 Primary and Foreign Keys
Identify each row uniquely and link tables safely with foreign keys.
primary keyforeign keyone-to-manyreferential integrity
-
Lesson 2 Combining Tables with INNER JOIN
Join related tables to show data from both, such as payments with student names.
INNER JOINON conditiontable aliasesjoining three tables
-
Lesson 3 LEFT JOIN and Missing Matches
Keep every row from one table even when the other has no match, and use that to find what is missing.
LEFT JOINunmatched rowsIS NULL after a joinCOALESCE with aggregates
Practical activity
Build students and payments tables for the school fees database and write joins that list payments with names and find students who have paid nothing.
Expected outcomes
- Correctly related tables
- Joins that answer cross-table questions
Assessment
Practical: write five join queries over a provided schema; marked on correct results including unmatched rows.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.