AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Relational databases: foreign key.
A foreign key is an attribute (or set of attributes) in one table that refers to the primary key of another table, creating a link between the two tables.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 8 of 9
Study notes
From the checked teaching notes for this specification point.
The idea
A foreign key is an attribute (or set of attributes) in one table that refers to the primary key of another table, creating a link between the two tables. In a school database, a Student table might hold StudentID as its primary key, while a Results table stores StudentID as a foreign key so each result can be traced back to the correct student. The foreign key value must match an existing primary key value in the referenced table, which enforces referential integrity: you cannot record a result for a student who does not exist. Unlike a primary key, a foreign key may repeat and may be null where the relationship is optional. Recognising foreign keys lets you trace relationships and join tables in queries.
What earns the marks
- Defines a foreign key as an attribute in one table that references the primary key of another table.
- States that a foreign key creates a link or relationship between two tables.
- Explains that foreign key values must match existing primary key values, enforcing referential integrity.
- Notes that a foreign key can repeat across rows and may be null, unlike a primary key.
- Applies the idea to an example, such as a Results table storing StudentID to link to a Student table.
Common mistakes and how to put them right
Confusing a foreign key with a primary key.
Put it right: A primary key uniquely identifies each row in its own table, whereas a foreign key refers to a primary key in another table.
Believing a foreign key must be unique.
Put it right: It can repeat, because many rows may relate to the same record in the other table.
Thinking a foreign key must be in the same table as the primary key it references.
Put it right: It sits in the referencing table and points to the other table.
Exam tips
- Learn a one-sentence definition plus a concrete two-table example you can recall quickly.
- When identifying a foreign key, check which field also appears as a primary key in another table.
- Remember the phrase 'refers to the primary key of another table' to distinguish it from a primary key.
Try the lesson
The start of the Relational databases: foreign key. lesson, made from checked teaching notes for this specification point.
Have a go first
In a relational database, what is the role of a foreign key in a table?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Relational databases: foreign key.
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge