National 5 Computing Science
Referential integrity: explaining it for the mark
National 5 Computing Science: Database design and development
A regular 1-mark question gives you an error message and asks why a record could not be added. The examiners' reports for 2023 and 2024 say the same thing: naming "referential integrity" is not enough. You have to explain it.
What it means
In two linked tables, the foreign key in one table points at the primary key in the other. Referential integrity means that a foreign key value must already exist as a primary key value in the linked table.
A league has teams 1, 2 and 3 in its Team table. Each player in the Player table has a teamID, which is a foreign key.
Adding a record that breaks it
INSERT INTO Player VALUES (17, "Ruaridh", "Bain", "Forward", 9);
The database rejects this, because there is no team with teamID 9 in the Team table. The new player would belong to a team that does not exist.
- "Because of referential integrity." (This just repeats the error message.)
- "The teamID is wrong." (Wrong how?)
- "There is no team with teamID 9 in the Team table, so the foreign key does not match an existing primary key."
Be specific: name the value, the field and the table.
Deleting a record that breaks it
It works the other way round too. If team 2 still has players, deleting team 2 from the Team table is refused: those players' teamID would point at a team that no longer exists.
Try two exam-style questions
Choose an answer, say how sure you are, then press Check. Every wrong answer tells you why it is wrong.

The full course covers every topic like this. Every topic in National 5 Computing Science has a short note, a simulation to try and a practice quiz with feedback on every answer, plus coding lessons, a full mock exam and a progress report for parents.
More guides
- SQL with two tables: the equi-join
- SQL UPDATE and INSERT without losing marks
- End-user and functional requirements
- All the free revision guides
This site is independent: it is not connected to the SQA or Qualifications Scotland. Points from the examiners' course reports are given in our own words.