← Years 7–8 Data & Information

Primary key

A field whose value is different for every record, such as a student ID or an AutoNumber, so each record can be identified. Names make a poor key because two people can share one.

Understanding Primary key in Years 7–8 Data & Information

What it does: Each student has a different ID number, so every record can be identified by it. Two different students can both be called Sam Nguyen, so the name cannot identify one record. A unique ID is better. Names can be shared. Two students called Sam Lee would be confused with each other. Every value in a primary key field must be different. The repeated 1002 breaks this rule. Two books could have the same title, or the library could own several copies. A unique ID number avoids this.

Common mistakes: Two students can share the same name, so Name cannot identify each record. The primary key should be StudentID, which is different for every student. An author can write many books, so the same Author value would appear in many records. The primary key should be BookID, which is unique for each book.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 9–45) and word search (Modules 9–80).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which field would make the best primary key for a table of students?
Student IDFirst name
Matches
Primary key = FirstName (Jack, Mia, Jack)
↓
FirstName has a repeated value (Jack twice), so it cannot identify each record. Use a unique field such as StudentID.
Applying
Meanings
Term
primary key
Meaning
A field whose value is different for every record, such as a student ID or an AutoNumber, so each record can be identified. Names make a poor key because two people can share one.
Practice
Table: Students
Testing
Gaps
Primary key:
Check Answer
Spots
1Primary key: Name
2Fields: StudentID, Name, Year

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Spider' badge — Web Weaver, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which field would make the best primary key for a table of students?
A. Student ID ✓
B. First name
A student ID is different for every student. Two students could easily share the same first name.
2. What does a primary key do?
A. Identifies each record in a table ✓
B. Makes the table look nicer
A primary key gives every record its own value so the record can be identified.
3. True or false: Two records in the same table can have the same primary key value.
A. True
B. False ✓
A primary key value must be different for every record. If two records shared one, you could not tell them apart.
4. Why is a name a poor choice for a primary key?
A. Names are too short to store
B. Two people can have the same name ✓
Names can be shared. Two students called Sam Lee would be confused with each other.
5. What does an AutoNumber field do in a database?
A. Creates a new, different number for each record ✓
B. Adds up all the numbers in the table
AutoNumber gives each new record the next number automatically, so no two records share a value.

Match the Pairs

Primary key → A field whose value is different for every record, so each record can be identified
AutoNumber → A field type that gives each new record the next unique number automatically, so it can be used as a primary key
A student ID is a good primary key because no two students share the same ID → StudentID: 10452, 10453, 10454
A name is a poor primary key because two people can share the same name → Name: Sam Nguyen, Sam Nguyen
Primary key = FirstName (Jack, Mia, Jack) → FirstName has a repeated value (Jack twice), so it cannot identify each record. Use a unique field such as StudentID.
StudentID: 101, 102, 102, 104 → The ID 102 appears twice, so the field is not unique. Each record needs its own ID, such as 103 for the third record.

Key Term

primary key
A field whose value is different for every record, such as a student ID or an AutoNumber, so each record can be identified. Names make a poor key because two people can share one.

Fill in the Blanks

1. Students: StudentID, Name, Year Primary key: StudentID
Hint: Type the field whose value is different for every student.
2. Field name: StudentNumber Data type: AutoNumber
Hint: Type the data type that makes a new unique number for each record automatically.
3. A primary key value must be unique
Hint: Type the word that means no two records can have the same value.
4. Fields: StudentID, Name, Year Two students can both be called Sam Poor primary key: Name
Hint: Type the field that two different people could share, so it is a poor key.
5. The field that identifies each record is called the primary key
Hint: Type the two-word term for a field that identifies each record.

Spot the Error

Question 1
A Primary key: Name
B Fields: StudentID, Name, Year
C Each StudentID is unique
Line A — Two students can share the same name, so Name cannot identify each record. The primary key should be StudentID, which is different for every student.
Question 2
A Table: Books
B Fields: BookID, Title, Author
C Primary key: Author
Line C — An author can write many books, so the same Author value would appear in many records. The primary key should be BookID, which is unique for each book.
Question 3
A StudentID | Name | Year
B 101 | Mia Lee | 7
C 102 | Tom Ray | 8
D 102 | Ava Ng | 7
Line D — The ID 102 is already used by Tom Ray. A primary key value must be different for every record, so this record should use a new ID such as 103.
Question 4
A PetID | AutoNumber | PK
B Add record: Rex -> PetID 1
C Add record: Bella -> PetID 2
D Add record: Milo -> PetID 2
Line D — AutoNumber gives each new record the next number and never repeats one. Milo should get PetID 3, because 2 already belongs to Bella.
Question 5
A Primary key rules:
B Every value can repeat
C A value cannot be left empty
Line B — A primary key must be different for every record, so values cannot repeat. The line should say every value must be unique.

Student with a class code? Join your class →