Primary Keys
- Each table has a primary key field which acts as a unique identifier
- Each item of data in this field is unique
- Duplicate data items would be blocked if they were entered into the primary key field
- Because the items of data are unique within the primary key field they can be used to identify individual records
A Database Table Containing Customer Details
|
|
|
|
|
1 |
Andrea |
Bycroft |
05031976 |
0746762883 |
2 |
Melissa |
Langler |
22012001 |
0756372892 |
3 |
Amy |
George |
22111988 |
0746372821 |
- In the example customer table, the primary key would be the CustomerID because each customer’s ID is unique
- If there was a customer with the same name they could be identified correctly using the CustomerID
Worked example
A database table containing the details of dogs
|
|
|
|
|
DG12 |
Smokey |
Poodle |
12 |
M |
DG34 |
Harvey |
Springer Spaniel |
10 |
M |
DG48 |
Maisie |
Labradoodle |
3 |
F |
DG49 |
Maggie |
Labradoodle |
3 |
F |
DG88 |
Winston |
Bulldog |
7 |
M |
DG95 |
Shona |
Golden Retriever |
6 |
F |
Which field would be suitable for the primary key? Explain why
[2]
DogID [1]
It is a unique identifier [1]
It does not contain any duplicate data items [1]