Cambridge O Level Computer Science · Syllabus 2210 · Databases
Primary Key
What is Primary Key?
A field whose value uniquely identifies each record in a database table, so that one key value always picks out exactly one record; it must have no duplicate values and must not be empty.
This definition is part of the Databases chapter in Cambridge O Level Computer Science.
Primary Key in context
A database is an organised collection of data that can be stored, searched and processed. Topic 9 works entirely with a database made of one table: data arranged in rows and columns, where a field is a column holding one category of data and a record is a row holding all the field values for one item. Every field is given a data type (text/alphanumeric, character, Boolean, integer, real or date/time) and, where a rule can be stated, one or more validation checks. One field is chosen as the primary key because its value is different in every record. SQL is then used to ask questions of that table — and the answer to “what does this query output?” is found by working through the clauses in a fixed order, never in the order they are written.
A design question gives you a paragraph describing what must be stored and asks you to define a table. The paragraph is not decoration — it is a checklist. Each separate item of data that the requirement says must be stored becomes exactly one field. You then give each field a meaningful name and a suitable data type, attach validation wherever the requirement states a rule, and choose a primary key. A field belongs in your design because a stated requirement puts it there, never because it would look realistic.
A primary key is a field whose value uniquely identifies each record in the table. Its purpose is to make every record findable and distinguishable: given one primary-key value, the database can return exactly one record, and no two records can ever be confused with one another. To be suitable, a field must have a different value in every record, must never be left empty, and should stay stable over time. That is the whole test — and it is a test about uniqueness, not about importance.
Topic 9 asks five kinds of question over and over: count something, choose a data type, choose a validation check, choose a primary key, and complete or interpret a query. Each has a shape. Learn the shape and you will never face a Topic 9 question with nothing to write — you fill the frame with the table in front of you.
Structure, data types, validation, primary keys, SQL completion and output interpretation, mixed together the way an examination mixes them. Every question refers to the BOOKING table earlier on this page — scroll back to it whenever you need to; that is exactly what you would do with a printed table in the exam. Answers are marked in this page only: nothing is stored and nothing is sent anywhere.
Common mistakes with Primary Key
- M2 — “A field is a row.” Why it is wrongIt swaps the two structural terms, and every later answer built on it — counting, data types, primary keys — goes wrong too. Correct“A field is a column: one category of data, with a field name and a data type.”
- M5 — “Every field must have unique values.” Why it is wrongOnly the primary key must be unique. Repetition in other fields is normal and useful — it is what makes filtering worth doing. Three bookings share GroupType of School, and that is the point. Correct“Only the primary key must have a different value in every record.”
- M6 — “AmountPaid is the primary key because it is the most important field.” Why it is wrongImportance is not the test. The test is uniqueness — and two bookings can easily pay the same amount. In BOOKING, 30.00 and 120.00 each appear twice. Correct“A primary key is the field whose value is different in every record, whether or not it is the most interesting field.”
- M7 — “GroupName would make a good primary key.” Why it is wrongNames repeat. Ashwood High School booked twice, so the value “Ashwood High School” identifies two records rather than one. Names also change, which breaks a key. Correct“Name fields are poor keys because two records can share a name and names can change. Use an issued identifier.”
- M8 — “A primary key has to be a number.” Why it is wrongNothing in the definition mentions numbers. B1041, A12 and PROD-0091 are all perfectly good keys, stored as text/alphanumeric. Correct“A primary key can be of any data type, as long as its value is unique in every record.”
- M13 — “A primary key is a type of validation check.” Why it is wrongThey answer different questions. Validation asks “is this entry reasonable?” A primary key answers “which record is this?” The named checks are range, length, type, presence, format and check digit. Correct“A primary key is a field that uniquely identifies each record; it is not one of the validation checks.”
- M23 — “COUNT(Places) gives the total number of places.” Why it is wrongCOUNT never looks at the size of a value, only at whether a value is there. Over the school bookings it gives 3, not 82. Correct“To total the places, use SUM(Places). To count the bookings, use COUNT on the primary key.”
Examiner tips on Primary Key
- The two repeats are deliberate. Ashwood High School appears twice and 07/03/2026 appears twice. Those repeats are what disqualify GroupName and SessionDate as primary keys, and they are also what makes sorting on SessionDate produce a genuine tie. Real exam tables contain repeats like these for exactly the same reason.
Questions students ask about Primary Key
Can a primary key be text rather than a number?
Yes. Nothing in the definition of a primary key mentions numbers. B1041, A12 and T104 are all perfectly good primary keys and are all stored as text/alphanumeric. The only requirement is that the value is different in every record.
What if no field in the table is unique?
Say so, and say what should be done: a new identifier field must be created and used as the primary key. That is a complete answer, and it is the expected answer whenever a scenario describes data with no natural identifier. Combining two fields into a single key is outside this syllabus.

