What is EER
• It is Enhanced ER Diagram (EER) or
• It is Extended ER Diagram (EER).
• It is an ER diagram + enhancement.
• Enhancements are:
– Subclasses, supercalasses, and inheritance.
– Specialization and generalization.
– Shared subclasses (Multiple Inheritance).
• Some times EER diagram is called E2R Diagram. 2
Subclasses, Superclasses, and
Inheritance
• In ER diagram, an entity type represents all entities
underneath it.
– Example, “Employee” represents all entities of employees.
• Sometimes, entities underneath an entity type can be
classified to specific entities which have its own
characteristics.
– Example, SalariedEmployee, Hourly Employee, Manager, Secretary,
Engineer, Technician.
– All the previous entity types are considered employees, but each has
its own unique attributes.
3
Subclasses, Superclasses, and
Inheritance
• SalariedEmployee, Hourly Employee, Manager, Secretary,
Engineer, and Technician are considered subclasses of
“Employee”.
• “Employee” is the superclass of all the previous types of
employees.
• We have a set of subclass/superclass connections
– Example: Manager/Employee
– Example: Secretary/Employee
4
Subclasses, Superclasses, and
Inheritance
• The connection between subclass and superclass is called
inheritance.
• A subclass inherits all attributes of its superclass.
– Example:
• Employee has a name, address, and birth_date.
• Each subclass of Employee such as manager, secretary, … etc has also
name, address, and birth_date which they inherit from the superclass
Employee.
5
Subclasses, Superclasses, and
Inheritance
• A subclass inherits all relationships of its superclass
– Example: Employee “works_for” Department
– All subclasses such as Manager, Secretary, … etc also “work_for”
Department.
6
Subclasses, Superclasses, and
Inheritance
• We classify an entity type into subclasses because each
subclass has its own unique attributes. (Local or Specific
Attributes).
• Example:
– Secretary has “typing_speed” attribute.
– Salaried_Employee has “salary” attribute.
– Hourly Employee has “payScale” attribute.
– Engineer has “eng_type” attribute.
– Technician has “Tech_grade” attribute.
7
Subclasses, Superclasses, and
Inheritance
• Subclasses can also have their unique relationships with other
entities. (Specific Relationships).
• Example 1:
– In company ER Diagram we had:
• Employee “manages” Department
• But, this relationship does not include all employees. (Only Managers)
– Now, in EER, instead of the above relationship. We have:
• Manager “manages” Department
• Example 2:
– HourlyEmployee “belongs_to” Trade_Union
• This relationship applies only to HourlyEmployee subclass
8
Subclasses, Superclasses, and
Inheritance
• Remember that an entity that belongs to a subclass also
belongs to its superclass.
• Example:
– Ahmad is a manager
– Ahmad is also an employee
• The point is: When an entity belongs to a specific subclass,
this does not omit the entity from the superclass.
9
Hierarchy Example
10
Specialization
• The process of defining subclasses of an entity type is called
specialization.
• This entity type is called “superclass” of the specialization.
• Specialization distinguishes between subclasses based on a
certain method:
– Example: Salaried Employee and Hourly Employee are grouped
together because they are classified based on paying method.
11
Specialization
• The Employee entity type has 3 specializations:
1) {SalariedEmployee,HourlyEmployee}
• Classified based on paying method.
2) {Manager}
• Has its own unique role (managing).
3) {Secretary, Technician, Engineer}
• Classified based on job type.
12
Specialization
• How specialization is represented in EER:
– Subclasses that define a specialization are attached by lines to a circle
that represents the specialization, which is connected to the
superclass.
• The subset symbol “U” on each line connecting a subclass to
the circle indicates the direction of the superclass/subclass
relationship.
• If the specialization contains only one subclass, we do not use
the symbol which is used for grouping subclasses.
13
Specialization
Superclass
Below this
Above this symbol is a
symbol is a subclass
superclass
subclass
14
Specialization
• Question: Why do we need subclasses and specialization?
• Answer:
1) Each subclass can have its own unique attributes
• Example: type_speed is a unique attribute of secretary.
2) Each subclass can participate in specific relationships
• Example: (Manager “manages” Department) is a specific relationship
between Manager and department. It is more specific than (Employee
“manages” Department).
15
Specialization
• In summary, specialization allows us to:
– Define subclasses of entity types.
– Define specific attributes for subclasses.
– Define specific relationships between subclasses and other entities or
subclasses.
16
Generalization
• Generalization is the reverse process of specialization.
• In generalization, you generalize a set of entity types into one
superclass entity type. Therefore, the generalized entity types
are considered subclasses.
• If you find a set of classes with many common attributes, they
can be considered subclasses and generalized to a common
entity (superclass).
17
Generalization
• Example, in an ER diagram you might have two entity types:
– Car
– Truck
• How can we generalize this?
18
Generalization
• The common attributes go to the superclass and the current
entity types (Car and Truck) become subclasses.
19
Generalization
• Notice that a generalization can be seen as a specialization
and vice versa.
• In generalization, we usually use the “is-a” relationship.
• It is used as “Subclass” “is-a” “Superclass”
– Staff “is-a” Employee
– Secretary “is_a” Employee
– Graduate_Student “is-a” Student
20
Constraints on Specialization and
Generalization
• Same constraints apply to specialization and generalization.
• From now on, we will discuss constraints on specialization.
But, keep in mind that they also apply to generalization.
21
Constraints on Specialization and
Generalization
• Based on Definition:
1) Predicate Defined Subclasses
2) User Defined Subclasses
• Based on membership
1) Disjoint Subclasses
2) Overlapping Subclasses
• Based on completeness of participation
1) Total Specialization
2) Partial Specialization
22
Based on Definition
(Predicate Defined Subclasses)
• It is also called Condition Defined Subclasses.
• We can determine to which subclass an entity belongs by
placing a condition on some attribute in the superclass.
• We call this attribute “Defining Attribute”.
• Example:
– JobType is an attribute of superclass “Employee”, based on the value
of this attribute, we can determine if an employee belongs to
“Secretary”, “Technician”, or “Engineer”.
23
Based on Definition
(Predicate Defined Subclasses)
• The attribute which determines membership to a subclass is called
“Defining Attribute”.
– Example: attribute “JobType”
• The condition which determines membership to a subclass is called
“Defining Predicate”.
– Example: JobType=‘secretary’
• If membership to a subclass is determined using value of some attribute,
then this subclass is called “Predicate Defined Subclass”.
• If all subclasses of a specialization have their membership condition on
the same attribute, then the specialization is called “Attribute-Defined
Specialization”.
24
Based on Definition
(Predicate Defined Subclasses)
• In EER:
– The “name” of the defining attribute is written on the line going “out
of” the superclass.
– The “value” of the defining attribute is written on the line going “into”
the subclass
25
Based on Definition
(Predicate Defined Subclasses)
• Example: Defining Attribute
Defining Attribute Value Defining Attribute name
26
Based on Definition
(User Defined Subclasses)
• If the membership in a subclass is not defined based on an
attribute, then this subclass is called “User Defined Classes”.
• If a DB user has an entity “A” to add to the database, then he
can use his understanding of the mini-world to determine to
which subclass entity “A” should be added.
27
Based on Membership
(Disjointness Constraint)
• Specifies that all subclasses of a specialization must be
disjoint.
• In other words, if an entity belongs to one subclass of a
specialization, then it cannot belong to another subclass of
the same specialization.
• Example:
– {Secretary,Technicien,Engineer} is a disjoint specialization.
– If an employee is a secretary, then she cannot be a technician
• The disjointness is represented in EER using d symbol.
28
Disjointness Constraint
• Example
Indicates a disjoint specialization
“d”: stands for “disjoint”.
29
Disjointness Constraint
• Question: If a specialization is “attribute-defined”, does this
mean that it is a “disjoint” specialization?
• Answer: If the defining attribute is:
– Single-Valued: then, the answer is “yes”.
– Multi-valued: then, the answer is “No”.
30
Based on Membership
(Overlapping Subclasses)
• Sometimes an entity can belong to more than one subclass of
the same specialization, this means that subclasses overlap
with each other.
• In EER, this is represented by using o notation.
31
Based on Membership
(Overlapping Subclasses)
• In a manufacturing company, the company can manufacture
some parts, the same parts can also be bought by the
company from a supplier.
• So, one part can be bought and manufactured at the same
time.
32
Based on Participation
(Completeness Constraint)
• Completeness constraint states that a specialization can be:
– Total Specialization or
– Partial Specialization
33
Based on Participation
(Completeness Constraint)
• Total Specialization:
– Every entity that belongs to a superclass must belong to at least one
subclass of the specialization
• Example: If “every” employee must be either an
HourlyEmployee or a SalaryEmployee then the specialization
{HourlyEmployee,SalaryEmployee} is a total specialization of
Employee.
• In EER, a total specialization is represented by using a double
lines that is going out of the superclass.
34
Based on Participation
(Completeness Constraint)
• Example
Indicates a total specialization
35
Based on Participation
(Completeness Constraint)
• Partial Specialization:
– Some entities might not belong to any of the subclasses of the
specialization
– In EER, it is represented as one line going out of the superclass.
• Example:
– If an employee is not a secretary, technician, or engineer, then he does
not belong to any of these subclasses of this specialization.
– So, the specialization {secretary, technician, engineer} is a partial
specialization.
36
Based on Participation
(Completeness Constraint)
Indicates a partial specialization
37
Note
• Disjointness and Completeness constraints are independent,
so you might have the following combinations of
specializations:
– Disjoint, total
– Disjoint, partial
– Overlapping, total
– Overlapping, partial
38
Example
Example of:
• Disjoint Partial Specialization
39
Note
• Deleting an entity from a superclass implies that it is automatically deleted
from all the subclasses to which it belongs.
– Example: Suppose that Ahmad is an engineer. If “Ahmad” is deleted from
superclass “Employee”, then he is deleted from subclass “Engineer”
• Inserting an entity in a superclass implies that the entity is mandatorily
inserted in all predicate-defined (or attribute-defined) subclasses for which
the entity satisfies the defining predicate.
– Example: If “Ahmad” is added to “Employee” superclass and he is an engineer,
then he should be added to “Engineer” subclass
• Inserting an entity in a superclass of a total specialization implies that the
entity is mandatorily inserted in at least one of the subclasses of the
specialization.
40
Specialization and Generalization
Hierarchies and Lattices
• In the specialization hierarchy that you have seen so far:
– There is one superclass for each subclass (One superclass/subclass
connection).
– There is only one level of superclass/subclass connections.
Secretary, Technician, and
Engineer, each of them has
only “one” superclass (Employee)
One level of
superclass/
subclass
41
Specialization and Generalization
Hierarchies and Lattices
• If we have a subclass that has multiple parents (superclasses),
then the hierarchy is called a “specialization lattice”.
– Multiple superclass/subclass connections for the same subclass.
• Having more than one superclass for the same subclass is also
called “Multiple Inheritance”.
42
Specialization and Generalization
Hierarchies and Lattices
• Example:
– Engineer_Manager is an engineer, a manager, and a salaried employee
at the same time.
– Engineer_Manager has 3 superclasses(Manager,Engineer,Salaried_Employee).
Here, we have 2 levels
Of superclass/subclass
connections
43
Specialization and Generalization
Hierarchies and Lattices
• Shared Subclass: A subclass with more than one superclass.
• Leaf Node: A class that has no subclasses of its own.
• In the previous example:
– Engineer is one of the “direct” superclasses of subclass
Engineer_Manager.
– Employee is an “indirect” superclass of subclass Engineer_Manager.
44
Lattice Example
45
Specialization and Generalization
Hierarchies and Lattices
• A subclass inherits all attributes of its direct superclasses and
indirect superclasses all the way up to the root of the lattice.
• Example:
– Research assistant inherits all attributes of superclasses
(Student_Assistant, Student, Employee, and Person)
46
Specialization and Generalization
Hierarchies and Lattices
• Person entity type is specialized into the subclasses
{Employee, Alumnus, Student}.
• Question: Is this specialization overlapping?
• Answer: Yes, because an employee in a university can be an
Alumni of the same university and at the same time studying
a different degree while he is working in the university.
47
Specialization and Generalization
Hierarchies and Lattices
• Some superclass and subclass connections in the university
example:
– The subclass “Student” is the superclass for the specialization
{Graduate_Student, Undergraduate_Student}.
– “Employee” is the superclass for the specialization {Student_Assistant,
Faculty, Staff}.
– “Student_Assistant” is also a subclass of “Student”.
– Finally, “Student_Assistant” is the superclass for the specialization
{Research_Assistant, Teaching_Assistant}.
48
Specialization and Generalization
Hierarchies and Lattices
• Note:
– If an attribute (or relationship) originating in the same superclass (eg.
Person) is inherited more than once via different paths (eg. Employee
and Student) in the lattice, then it should be included only once in the
shared subclass (eg. Student_Assistant).
– For example, Employee and Student both inherit attribute address
from Person. Now, Student_Assistant inherits only one “address”
attribute (from either Student or Employee).
49
Definition
• Top-down conceptual refinement process:
– The process of defining general entity types first, then repeatedly
apply specialization to find more specific entity types.
– In other words, it is a repeated specialization process.
• Example: In a registration DB:
– We think of “Person” entity type first.
– Then we define {Employee,Alumnus,Student} as a specialization of
Person.
– Then we define a specialization for Employee.
– Then the process can be repeated until we are satisfied with our
design.
50
Definition
• Bottom-up conceptual synthesis:
– The process of defining specific entity types first, then we group these
entity types into a common (more general) entity types.
– In other words, it is a repeated generalization process.
• Example
– We think of Staff, Faculty, Student_Assistant first.
– Then we generalize {Staff,Faculty,Student_Assistant} into Employee
superclass.
– Then we realize that Student_Assistant should also be a subclass of
Student.
– The process is repeated until we are satisfied with our design.
51
University EER
52