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.
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.
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.
Purpose: to identify each record uniquely, so that one particular record can always be found, updated or deleted without affecting any other.
Unique: no two records may have the same value in the primary key field. The database rejects a new record that repeats a key value.
Not empty: every record must have a value in the primary key field.
One per table: each table has one primary key field.
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?
MemberID
FirstName
Surname
Town
DateJoined
M001
Ana
Silva
Leeds
03/01/2025
M002
Ben
Silva
York
17/02/2025
M003
Ana
Khan
Leeds
05/06/2025
M004
Chen
Wu
York
22/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.
FirstName repeats (Ana twice), Surname repeats (Silva twice) and Town repeats (Leeds and York twice each).
DateJoined happens to be different in these four records, but two people could join on the same day, so it is not guaranteed unique.
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?
Registration: every car has its own number plate, while makes, models and colours repeat.
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.
Add an ID field: StudentID, OrderNumber, BookID. The database or the organisation gives each new record the next unused value, such as S1001, S1002 and so on.
Good natural keys: some real-world codes are already unique, such as a car registration or a book's ISBN.
Data type: an ID such as M001 or P07 mixes letters and digits, so it is text/alphanumeric. A purely numeric ID such as 1001 can be integer.
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.