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
| Type | Meaning | ER symbol | Example |
|---|---|---|---|
| Simple (atomic) | Can't be split | plain oval | gender, salary |
| Composite | Splits into sub-parts | oval with sub-ovals | name β (first, middle, last) |
| Single-valued | One value per entity | plain oval | date_of_birth |
| Multi-valued | Many values per entity | double oval | phone_numbers |
| Derived | Computed from others | dashed oval | age (from DOB) |
| Key | Uniquely identifies | underlined | student_id |
| Null / optional | May have no value | plain oval | middle_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
| Key | Definition |
|---|---|
| Super key | Any attribute set whose values identify a unique tuple (may contain extra attributes). |
| Candidate key | A super key that is minimal β remove any attribute and it stops identifying. |
| Primary key | The one candidate key chosen to identify the entity set. |
| Foreign key | An attribute whose value must exist as a primary key in a referenced relation. |