Understand the purpose of a primary key
Use a primary key to distinguish one table record from every other record.
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
Could two records share a primary-key value if it must identify each row?
What you will learn
- Explain how a key identifies a record
- Recognise that key values must distinguish records
- Explain why repeated descriptive values may not work as keys
A primary key identifies one record
A primary key is a field, or a suitable set of fields, used to identify one record uniquely in a table. It lets a program refer to one specific row.
A suitable key must distinguish every record. If two rows can share the same value, that field cannot identify each row on its own.
Descriptive values may repeat or change
Names, titles and dates can often be shared by several records. They may also change, so they are commonly poor identifiers.
An allocated ID is often a better choice when each record receives a distinct value. Explain the reason using the table's actual data, not only the field's name.
Pause and explain
A table contains several performances with the same Type. Is Type suitable as the primary key?
Worked example
A table has two bookings for the same learner on the same date. Could LearnerName alone identify each booking?
Show the worked solution
- The two records have the same learner name.
- A name does not distinguish the bookings.
- Use a distinct BookingID or another key that is unique for every row.
Answer No. LearnerName can repeat, so it is not a suitable single-field primary key here.
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 student table has StudentNumber, Name and YearGroup. Which field is most likely to be a primary key and why?
Give me a hint
Look for a value assigned to distinguish each student.
Compare my reasoning
- Names may repeat.
- Many students may share a year group.
- A unique student number can identify each record.
StudentNumber, if each student receives a distinct number.
Look for these in your work
- Candidate chosen
- Uniqueness reason
A product table has Category, Brand and ProductCode. What evidence would you need before selecting ProductCode as the key?
Give me a hint
Do not assume the field name guarantees uniqueness.
Compare my reasoning
- Check whether every product has a code.
- Check that no two records share a code.
- Confirm the code identifies one product consistently.
Evidence that ProductCode is present and unique for every product record.
Look for these in your work
- Presence
- Uniqueness
- Identification
A theatre uses Title as a primary key, but two productions can share a title. Explain the failure and propose a correction.
Give me a hint
The key must separate the two records even when descriptive data repeats.
Compare my reasoning
- Both productions could have the same Title.
- The key would not identify one row unambiguously.
- Add or use a unique ShowNumber.
Title can repeat; use a unique ShowNumber to distinguish each production record.
Look for these in your work
- Duplicate explained
- Unique field proposed
Common mistakes
- Assuming a field is unique just because it sounds like an ID
- Choosing a name when duplicates are possible
- Confusing a primary key with a field used only for sorting
What can you explain now?
What is the purpose of a primary key?
Compare with the explanation
To identify each record uniquely
A key distinguishes one row from the other 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
What property makes a field suitable as a primary key?
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.