Databases: Primary, Foreign and Alternate Keys

Jump to: navigation, search

This introduces some terminology frequently used in relations databases.

In a database table, certain columns are keys. Keys help identify rows / records and link records together.

Primary Key

Uniquely identifies a record/row/object/person.

Alternate Key

Also uniquely identifies a record/row/object/person

Foreign Key

Related tables are linked together by taking the primary key from one table and placing in the related table. The primary key then becomes a foreign key.

In this case, if we had another table that described Institutions', then the Institution column in the Instructors table would be a foreign key.


The Instructors table, again.

Instructor Table
Primary Key Foreign Key? Alternate Key
Participant Affiliation Email
Scott Cain Ontario Institute for Cancer Research
Tim Carver Sanger Institute
Dave Clements NESCent
Stephen Ficklin Clemson University
Syed Haider EBI
Ian Holmes UC Berkeley
Carson Holt University of Utah carson.holt@utah.ed
Robin Houston Sanger Institute
Ed Lee Lawrence Berkeley National Lab
Sheldon McKay Cold Spring Harbor Laboratory
Joshua Orvis Institute for Genome Sciences
Mitch Skinner UC Berkeley
Giles Velarde Wellcome Trust Sanger Institute
Junjun Zhang Ontario Institute for Cancer Research


This simplified table contains a number of bad practices, such as the primary and foreign key values used, and naming conventions. We'll get to those.

Back to Chado Tutorial.