Primary and foreign keys – OCR A Level Computer Science lesson (H446)
Students learn to identify primary and foreign keys in a set of tables and explain how they link records.
Lesson 7 of 12 in unit 12.11 Compression, Encryption, Hashing and Databases, taught in Year 12, Summer 2. It answers one big question: How do tables know which records belong together?
By the end, students can identify primary and foreign keys in a set of tables and explain how they link records.
- The Build (the main task)
- Identify the primary key and any foreign keys in Shutterbox's Member, Photo and Entry tables, and explain how the keys link a photo to its member (5 marks).
- Support version
- The three tables printed with sample records, with the prompt 'Could this value ever repeat or be blank?' beside each field.
- Challenge
- Explain why the Entry table needs a composite primary key, and what would go wrong if PhotoID alone were used.
- Real-world link
- Shutterbox's first relational design: Member, Photo and Entry tables.
- Key words
- Primary key, Foreign key and Unique, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “A foreign key must be unique in its own table”; “Any field whose values all happen to be different can be the primary key”.
- OCR H446 specification
- 1.3.2 (a).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Students can do it all on paper.
Also sold in the Compression, Encryption, Hashing and Databases unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
An independent resource written for OCR A Level Computer Science (H446). It is not endorsed by OCR or Cambridge University Press & Assessment. Programming project (NEA) lessons teach general skills on a made-up example project and give supervised time, within JCQ's rules on the help a centre may give.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for A Level Computer Science
See allStudents learn to compare lossy and lossless compression and justify which suits a given type of file.
Free sample lessonStudents learn to apply run length encoding and dictionary coding to data and calculate whether the result is smaller.
Students learn to describe symmetric and asymmetric encryption and state whose key encrypts and decrypts in each.
Written for the specifications named. Not endorsed by or affiliated with any exam board.