Related tables and keys

About this lesson: Related tables and keys

In short

Putting students and their results in one table repeats names and classes in many rows. Look at the problems this causes.

Related tables and keys

What you'll explore

One big table: What goes wrong?
Putting students and their results in one table repeats names and classes in many rows. Look at the problems this causes.
Two related tables: Link with a key
Split the data into Students and Results. StudentID links them. Choose a student to see which results belong to them.
Keys: Primary and foreign
A primary key identifies each record. A foreign key holds another table's primary key, creating the link.
Check yourself: Foreign key
A Loans table records which library member borrowed each book. It has LoanID, MemberID and BookID.

Also in this lesson

  • Common mix-ups
  • Students and Results
  • Library cards

Words to know

relational database
A database of tables linked by keys.
record
One row: all the data about one item.
field
One column: one kind of data.
primary key
A field that is unique for each record.
foreign key
A field that links to another table's primary key.

Sources

  • BBC Bitesize KS3 Computer Science
  • Raspberry Pi Foundation, Computing curriculum resources

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 4 short steps and a 6-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 11 November 2026.

← Building and checking a spreadsheet model

All lessons in Term 2 · Computing · Age 13