Primary Keys (Cambridge (CIE) O Level Computer Science)

Revision Note

James Woodhouse

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 5 free revision notes this week

Sign up now. It’s free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.

Lucy Kirkham

Author: Lucy Kirkham

Expertise: Head of STEM

Lucy has been a passionate Maths teacher for over 12 years, teaching maths across the UK and abroad helping to engage, interest and develop confidence in the subject at all levels.Working as a Head of Department and then Director of Maths, Lucy has advised schools and academy trusts in both Scotland and the East Midlands, where her role was to support and coach teachers to improve Maths teaching for all.