Choose a suitable primary key from a table
Compare candidate fields against the actual records and select a unique identifier.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6, Topic 9. It covers single-table databases only and the specified SELECT, FROM, WHERE, ORDER BY, SUM, COUNT, AND and OR content. The official specimen also demonstrates NOT in a filter. Multi-table joins, GROUP BY, database implementation and the separate 2029–2031 syllabus are not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding.
Before you begin
- Be able to read a small table and compare values. Each lesson introduces the database and SQL terms it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What should you inspect before selecting a key?
What you will learn
- Test whether candidate values repeat
- Distinguish unique data from likely unique data
- Justify a key choice from table evidence
Use the table as evidence
Inspect the values in each candidate field. A key is unsuitable if any two records share the same value or if a required value is missing.
A field may appear unique in a small sample but still be allowed to repeat by its meaning. Explain whether the data rule guarantees uniqueness, not only whether current rows happen to differ.
Prefer stable identifiers
A code specifically assigned to one record is generally more dependable than a mutable description such as title or address.
If no single field is unique, a combination may distinguish rows, but the Cambridge question often expects you to state that none of the listed fields is suitable and give a reason.
Pause and explain
An example table shows unique names, but names are not guaranteed unique for future records. What is the best conclusion?
Worked example
Rows show ShowNumber SN11, SN12, SN13; Type Jazz, Drama, Jazz; Title Blue, Blue, Night. Which field is suitable as the key?
Show the worked solution
- ShowNumber differs in each record.
- Type repeats Jazz.
- Title repeats Blue.
Answer ShowNumber is suitable because the shown records have distinct values; Type and Title are not unique.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
A table lists RoomCode R1, R2, R3 and Capacity 20, 20, 30. Which field can distinguish these rooms?
Give me a hint
Check which values repeat.
Compare my reasoning
- Capacity repeats 20.
- RoomCode has distinct values in the rows.
- RoomCode is the suitable candidate based on the table.
RoomCode; Capacity is not unique.
Look for these in your work
- Duplicate detected
- Candidate justified
A customer table includes Email, Surname and CustomerNumber. Give one reason CustomerNumber may be a better key than Email.
Give me a hint
Consider stability and assigned identity.
Compare my reasoning
- Email addresses may change.
- Surnames can repeat.
- A distinct assigned number can remain the record identifier.
CustomerNumber may be a stable unique identifier, while email can change and surnames can repeat.
Look for these in your work
- Alternative limitations
- Key rationale
The only fields available are Type and Date, and two rows share both values. Explain why neither field alone nor their combination identifies every row.
Give me a hint
Test the duplicate pair against each candidate.
Compare my reasoning
- Type repeats.
- Date repeats, and the Type-Date pair repeats together.
- A new unique identifier is needed.
Neither is unique, and combining them still leaves duplicate pairs; add a unique ID field.
Look for these in your work
- Single-field test
- Combined-key test
- Design fix
Common mistakes
- Choosing the field with the most varied values without checking duplicates
- Claiming current uniqueness when the field's meaning allows repeats
- Using a value that can change as the record's identity
What can you explain now?
If a candidate field repeats in two rows, can it identify each row alone?
Compare with the explanation
No
A repeated value does not distinguish those records.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
Why is a unique-looking sample value not always enough to prove key suitability?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.