Entities, Attributes & Keys

Lecture 3 Β· the ER model has just three building blocks β€” entity sets, relationship sets and attributes. This page covers entities, attributes and keys.

Entity & entity set

  • Entity β€” an object that exists and is distinguishable (a specific person, a company).
  • Entity set β€” a set of entities of the same type sharing the same properties (all persons).
  • An entity is described by attributes: e.g. person = (person_ID, name, age, DOB, national_ID).

Attribute types

TypeMeaningER symbolExample
Simple (atomic)Can't be splitplain ovalgender, salary
CompositeSplits into sub-partsoval with sub-ovalsname β†’ (first, middle, last)
Single-valuedOne value per entityplain ovaldate_of_birth
Multi-valuedMany values per entitydouble ovalphone_numbers
DerivedComputed from othersdashed ovalage (from DOB)
KeyUniquely identifiesunderlinedstudent_id
Null / optionalMay have no valueplain ovalmiddle_name
Domain = the set of permitted values for an attribute. e.g. student_age ∈ {0..120} β†’ 19 valid, βˆ’3 or β€œtwenty” invalid.

Keys β€” the nesting hierarchy

Super keyenough to identify a row (may have extras)Candidate keya MINIMAL super keyPrimary key β€” one chosen candidateForeign keyvalue must appearas a PK in anotherrelation
KeyDefinition
Super keyAny attribute set whose values identify a unique tuple (may contain extra attributes).
Candidate keyA super key that is minimal β€” remove any attribute and it stops identifying.
Primary keyThe one candidate key chosen to identify the entity set.
Foreign keyAn attribute whose value must exist as a primary key in a referenced relation.