Enhanced Entity Relationship Model: Elements of The EER Model
Enhanced Entity Relationship Model: Elements of The EER Model
1
• In practice specializations and generalizations can often not be distin-
guished
2
Differences with regard to object-oriented programming
• Multiple overlapping specializations can apply to the same entity, e.g.,
A student may be a GradStudent or UnderGradStudent, and in either
case he/she may or may not be an Assistant
Constraints on specializations
Defining predicate
• Sometimes an attribute is used to specify the subclass
Disjointness constraint
• A specialization is disjoint if each real world entity can belong to one
subclass at most, e.g.,
Completeness constraint
• A specialization is mandatory if each real world entity hast to belong
to at least one subclass, e.g.,
3
– Every student has to be either an undergraduate or a graduate
student (assuming there are no non-degree students)
A library has books and wants to save special information for text-
books and for novels. Mandatory or optional specialization?
Optional if we assume that the library has other books, too.
4
Examples
Mandatory Optional
Disjoint Faculty has to be part-time Library books can be
or full-time and nothing else textbooks or novels (assuming
no novel is a textbook)
Overlapping Persons in the NDSU database A conference gives a special
can be students, employees, status to members of some
or alumni (assuming all professional associations
have some relationship to NDSU)
Modeling Alternatives
Assume that there are N subclasses
• N + 1 tables: One table for each subclass plus one table for the super-
class
• N tables: One table for each subclass, which also holds the superclass
attributes
• The primary key of the superclass is not only used as foreign key in the
subclasses, but also as their primary key (as for 1-to-1 relationships)
• Space efficiency trade-off: Foreign keys use some space, but the solution
avoids null values
5
• Preferable when there are many subclass attributes
Student
PK student_id
name
address
Undergrad Grad
PK, FK student_id PK, FK student_id
level grad_standing
6
UndergradStudent GradStudent
PK student_id PK student_id
name name
address address
level grad_standing
• Space-tradeoff: No need for foreign keys, but null values use space
Student
PK student_id
name
address
is_grad
level
grad_standing
7
Category
• So far we only had a shared subclass of classes that originated from a
single superclass