Primary key

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Primary key

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which field would make the best primary key for a table of students?
A Student ID
B First name
2. What does a primary key do?
A Identifies each record in a table
B Makes the table look nicer
3. True or false: Two records in the same table can have the same primary key value.
A True
B False
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
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

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

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

Definitions

primary key

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Students: StudentID, Name, Year Primary key: _________
2.
Field name: StudentNumber Data type: __________
3.
A primary key value must be ______
4.
Fields: StudentID, Name, Year Two students can both be called Sam Poor primary key: ____
5.
The field that identifies each record is called the ___________

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Primary key: Name
B Fields: StudentID, Name, Year
C Each StudentID is unique
Question 2
A Table: Books
B Fields: BookID, Title, Author
C Primary key: Author
Question 3
A StudentID | Name | Year
B 101 | Mia Lee | 7
C 102 | Tom Ray | 8
D 102 | Ava Ng | 7
Question 4
A PetID | AutoNumber | PK
B Add record: Rex -> PetID 1
C Add record: Bella -> PetID 2
D Add record: Milo -> PetID 2
Question 5
A Primary key rules:
B Every value can repeat
C A value cannot be left empty

Answer Key

Primary key
Section A: Quick Questions
Q1
A — Student ID
Q2
A — Identifies each record in a table
Q3
B — False
Q4
B — Two people can have the same name
Q5
A — Creates a new, different number for each record
Section B: Match the Pairs
Q1
Primary key → A field whose value is different for every record, so each record can be identified
Q2
AutoNumber → A field type that gives each new record the next unique number automatically, so it can be used as a primary key
Q3
A student ID is a good primary key because no two students share the same ID → StudentID: 10452, 10453, 10454
Q4
A name is a poor primary key because two people can share the same name → Name: Sam Nguyen, Sam Nguyen
Q5
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.
Q6
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.
Section C: Definitions
Q1
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.
Section D: Fill in the Blanks
Q1
Students: StudentID, Name, Year Primary key: StudentID
Q2
Field name: StudentNumber Data type: AutoNumber
Q3
A primary key value must be unique
Q4
Fields: StudentID, Name, Year Two students can both be called Sam Poor primary key: Name
Q5
The field that identifies each record is called the primary key
Section E: Spot the Error
Q1
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.
Q2
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.
Q3
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.
Q4
D — AutoNumber gives each new record the next number and never repeats one. Milo should get PetID 3, because 2 already belongs to Bella.
Q5
B — A primary key must be different for every record, so values cannot repeat. The line should say every value must be unique.