Databases: Primary, Foreign and Alternate Keys

From GMOD

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.

Example

The Instructors table, again.

Instructor Table
Primary Key Foreign Key? Alternate Key
Participant Affiliation Email
Scott CainOntario Institute for Cancer Researchscott@scottcain.net
Tim CarverSanger Institutetjc@sanger.ac.uk
Dave ClementsNESCentclements@nescent.org
Stephen FicklinClemson Universityficklin@clemson.edu
Syed HaiderEBIsyed@ebi.ac.uk
Ian HolmesUC Berkeleyihh@berkeley.edu
Carson HoltUniversity of Utahcarson.holt@utah.ed
Robin HoustonSanger Instituterh11@sanger.ac.uk
Ed LeeLawrence Berkeley National Labelee@berkeleybop.org
Sheldon McKayCold Spring Harbor Laboratorymckays@cshl.edu
Joshua Orvis Institute for Genome Sciencesjorvis@som.umaryland.edu
Mitch SkinnerUC Berkeleymitch_skinner@berkeley.edu
Giles VelardeWellcome Trust Sanger Institutegv1@sanger.ac.uk
Junjun ZhangOntario Institute for Cancer ResearchJunjun.Zhang@oicr.on.ca

Note

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.

Personal tools
Documentation
Developers