Cambridge IGCSE · Topic 9 (1-3)
IGCSE Computer Science 0478 / Topic 9 / IGCSE

One field, no repeats.

Two students can share a name, a birthday and a town, yet the school must never mix up their records. A primary key gives every record a value that no other record has, so the database can always find exactly the right one.

The key idea

A primary key is a field that uniquely identifies each record in a table. Its value must be different for every record and must never be empty. Names, towns and dates are poor choices because values can repeat. When no existing field is guaranteed to be unique, the database designer adds an ID field, such as MemberID or BookID, to act as the primary key.

which field could be the primary key? MemberIDFirstNameSurnameTown M001M002M003M004 KhanWu BenChen AnaAna SilvaSilva LeedsYorkLeedsYork ✓ unique ✗ values repeat, so not unique a primary key value is never repeated and never empty
Fig. 1: only MemberID has a different value in every record, so it is the primary key
Section 01

What a primary key is for.

In the lab, try each field of the Books table as the primary key. The lab tests every value in that column: if any value repeats, or any is empty, the field fails.

Examiner trap

"A primary key is the first field" or "the most important field" earns nothing. The mark is for uniquely identifies each record.

Section 02

Spotting a suitable key.

Go through the fields one at a time. For each, ask two questions: could two records ever share this value, now or in future? Could the value ever be missing?

MemberIDFirstNameSurnameTownDateJoined
M001AnaSilvaLeeds03/01/2025
M002BenSilvaYork17/02/2025
M003AnaKhanLeeds05/06/2025
M004ChenWuYork22/09/2025
Worked example Members table
Identify the most suitable primary key for the table above and explain why each other field is not suitable.
  1. FirstName repeats (Ana twice), Surname repeats (Silva twice) and Town repeats (Leeds and York twice each).
  2. DateJoined happens to be different in these four records, but two people could join on the same day, so it is not guaranteed unique.
  3. MemberID is different for every member and is given to every member when they join.
Answer: MemberID
Your turn
A table CARS has fields Make, Model, Colour and Registration (number plate). Which field is the most suitable primary key?
Examiner trap

Do not choose a field just because its values are all different in the sample shown. It must be unique for every record that could ever be added.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What is the purpose of a primary key?

Quick check+10 XP

In the lab's primary key test on the Books table, why does the Author field fail?

Quick check+10 XP

A primary key field must have which two properties?

Quick check+10 XP

Which field is most suitable as the primary key of a table of school students?

Section 03

When there is no natural key.

Many real tables have no field that is guaranteed to be unique. The fix is to add a new field whose only job is to be the key.

Examiner trap

An email address may look unique, but people change addresses and some share family accounts. In an exam, an ID field is the safest choice when one is given.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

A table BOOKS has the fields Title, Author, ISBN and Genre. Which field should be the primary key?

Exam style+20 XP

Why is Surname not a suitable primary key for a table of customers?

Exam style+20 XP

A user tries to add a record whose primary key value already exists in the table. What happens?

Exam style+20 XP

A table of exam entries has fields CandidateNumber, Subject and Grade. Each candidate takes several subjects. Why is CandidateNumber not a suitable primary key?

Skill unlocked

Primary keys, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
The purpose of a primary key and how to identify a suitable primary key field for a table.