Skip to content

Primary And Foreign Keys

Primary keys

The primary key is a field that uniquely identifies each record.

Example

  • Everyone has a unique SQA candidate number.

  • Cars have a unique registration.

At National 5 you need to be able to identify the primary key from a given table.

Foriegn Keys

When a field from one table or entity appears in another table or entity, it is called a foreign key.

The foreign key is a field that both tables have in common.

Example

  • MovieID is the primary key for Movie,

and

  • DirectorID is the primary key for Director.

Because DirectorID - the primary key from Director - also appears in the Movie table, that makes it a foreign key.

Compound Keys