Skip to content

Primary Key

A primary key is the attribute / set of attributes by which we can distinctly identify a: 1) Entity 2) Relationship 3) Weak Entity

Entity

  • Each entity in an entity set is distinct
  • To materialise this distinctness, the primary key is used. No two entities are allowed to have the same primary key

Relationship

  • Let R be a relationship involving n entities, {Ei}n
  • The primary key for R is the union of the primary keys of each set in {Ei}n
  • If the relationship set has attributes {Ai}m associated with it, then its primary key will also have {Ai}m associated with it
Choosing based on cardinality of relationship
  • Many-to-Many: The preceding union of primary keys is a minimal superkey, and is chosen as the primary key
  • One-to-Many: The primary key of the "Many" side is a minimal superkey and is used as the primary key
  • One-to-One: The primary key of either one of the participating entity sets can count as the primary key

Weak Entity

  • A weak entity can be discriminated using the foreign key pointing to the identifying entity, on which it relies for existence