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
be a relationship involving entities, - The primary key for
is the union of the primary keys of each set in - If the relationship set has attributes
associated with it, then its primary key will also have 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