AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Relational databases: primary key
A primary key is a field (or set of fields) in a table that uniquely identifies each record, so no two rows share the same key value and the key cannot be empty.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 7 of 9
Study notes
From the checked teaching notes for this specification point.
The idea
A primary key is a field (or set of fields) in a table that uniquely identifies each record, so no two rows share the same key value and the key cannot be empty. In a table of library books, a BookID field could act as the primary key because each book has a distinct identifier, whereas a Title field would not, since two books could share a title. The primary key enforces entity integrity and is used to link tables: a foreign key in another table refers to the primary key to create a relationship. Choosing a suitable primary key means picking a field guaranteed to be unique and stable, such as an assigned ID rather than a name that might change or repeat. A candidate question asks you to identify which field could serve as a primary key, so check uniqueness and non-null requirements.
What earns the marks
- A primary key uniquely identifies each record in a table.
- No two records may share the same primary key value, and the key cannot be empty.
- A suitable primary key is a field guaranteed unique and stable, such as an assigned ID.
- A field such as a name or title is usually unsuitable because values can repeat or change.
- A primary key can be referenced by a foreign key in another table to form a relationship.
- The primary key helps enforce entity integrity and prevents duplicate records.
Common mistakes and how to put them right
Choosing a field such as a name or title as a primary key.
Put it right: Such values can repeat or change, so an assigned unique ID is preferred.
Believing a primary key may be left blank.
Put it right: A primary key must always hold a unique, non-null value.
Confusing a primary key with a foreign key.
Put it right: A primary key uniquely identifies records in its own table, while a foreign key refers to a primary key in another table.
Exam tips
- Test each candidate field for uniqueness across all records before selecting it.
- Reject fields whose values could change or repeat, such as names or dates.
- Remember the primary key must be non-null as well as unique.
Try the lesson
The start of the Relational databases: primary key lesson, made from checked teaching notes for this specification point.
Have a go first
In a relational database table, what is the main purpose of a primary key?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Relational databases: primary key
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge