Primary Keys (Cambridge (CIE) IGCSE Computer Science)
Revision Note
Written by: James Woodhouse
Reviewed by: Lucy Kirkham
Primary Keys
What is a primary key?
A primary key is a unique field that can be used to identify a record in a table
customer_id is the primary key for the customers table below
Other examples of primary keys in database tables would include:
Student_ID in a school database
Car_Registration in a car database
Product_ID in a shop database
CustomerID | FirstName | LastName | DOB | PhoneNumber |
---|---|---|---|---|
001 | Andrea | Bycroft | 05031976 | 0746762883 |
002 | Melissa | Langler | 22012001 | 0756372892 |
003 | Amy | George | 22111988 | 074637 |
Key database terminology
Term | Definition |
---|---|
Table | A collection of records with a similar structure |
Record | A group of related fields, representing one data entry |
Field | A single piece of data in a record |
Data type | Type of data held in a field |
Primary key | A unique identifier for each record in a table. Usually an ID number |
Foreign key | A field in a table that refers to the primary key in another table. Used to link tables and create relationships |
Worked Example
A database has been developed for a dance club to store information about their members.
The database contains one table: Members
Figure A shows some data from the table.
Members
MemberID | FirstName | LastName | DateJoined |
1 | Zarmeen | Hussain | 2024-01-19 |
2 | Fyn | Ball | 2024-02-01 |
3 | George | Johnson | 2024-02-25 |
4 | Ella | Franks | 2024-03-04 |
State the name of the field from the Members table that is the most suitable to use as the primary key [1]
Answer
(a) MemberID
Last updated:
You've read 0 of your 10 free revision notes
Unlock more, it's free!
Did this page help you?