Secondary key
A non-primary field used to search or sort records, such as surname. Unlike a primary key, its values need not be unique, and it is often indexed to make searches faster.
Understanding Secondary key in QCE Digital Solutions Unit 2
What it does: Sorting by lastName uses a secondary key. Two students can share a surname, so the values need not be unique. A secondary key is a non-primary field used to search or sort. studentId is already the primary key, so surname is the secondary key here. An index works like a sorted lookup list so the database can find matching records without checking every row. It does not make values unique. CREATE INDEX name ON table(field) builds an index on the chosen field. CREATE KEY is not valid SQL for this. The broken statement confuses secondary keys with primary keys. Uniqueness is the rule for a primary key only.
Common mistakes: The index is meant to speed up searches by surname, so it must be built on the secondary key lastName. studentId is the primary key and already has an index. It should be ON students(lastName);. lastName is not unique because many students can share a surname, so it is a secondary key, not a primary key. The comment should say secondary key: lastName.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 186–228) and word search (Modules 144–228).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
secondary keyFill in the Blanks
Spot the Error
Student with a class code? Join your class →