Professional Documents
Culture Documents
The ER and EER Model
The ER and EER Model
Routes
Duration Date
The Whole Diagram
• N-ary
Cardinality Ratio
• Expresses the # of entities to which
another entity can be associated via a
relationship set
– 1:1—Employee manages department
– 1:N—Mother having children
– N:1—Children having mothers
– M:N—Students enrolled courses
Binary Relationships
• 1:1: An entity in A is associated with at most one
entity in B and an entity in B is associated with at
most one entity in A
• 1:N: An entity in A is associated with any
number of entities in B. An entity in B, however,
can be associated with at most one entity in A
• M:N: An entity in A is associated with any
number of entities in B and an entity in B is
associated with any number of entities in A
Binary Relationships
• Relationships involving two entity sets
(binary relationships) can be classified as
1-to-1, 1-to-Many (Many-to-1) or Many-to-
Many
since
name dname
ssn addr did budget
Employees Work_for
N 1 Departments
Participation
• Specifies whether the existence of an
entity depends on its being related to
another entity via the relationship set
• Two types
– Total
– Partial
Total Participation
• Every employee must work for a
department, then every employee in
Employee entities must be related to a
department entity via Works_For
relationship (represented by double line)
name dname
ssn did
Supervision Employee
N Supervisee
Employees
Monitors until
started_on since
dname
pid pbudget did budget
from Duration to
Entity vs. Relationship
• First ER diagram OK if a
since dbudget
manager gets a separate name dname
discretionary budget for ssn lot did
each dept
• What if a manager gets a Employees Manages2 Departments
1 N
discretionary budget that
covers all managed
depts?
name dname
– Redundancy of
ssn lot did
dbudget, which is
stored for each dept Employees Manages3 Departments
managed by the
manager
– Misleading: suggests since
dbudget tied to apptnum Mgr_Appts
managed dept dbudget
Binary vs. Ternary Relationships
Weak Entity
Relationship
Identifying Relationship
Attribute
Key Attribute
Summary of ER (Contd.)
Symbol Meaning
Multi-valued
Composite Attribute
Derived Attribute
Summary of ER (Contd.)
Symbol Meaning
E1 R E2 Total Participation of E2 in R
1 N
E1 R E2 Cardinality Ratio 1:N for E1:E2 in R
DNumber
Name
Salary Addr
1
1 No-Emp
Supervision Employee N department
Works For
1
N 1 Name 1
SSN location
M
Controls
manages
N
Dependents
Works-on Project
N Location
N Hours Number
Name
Name Dependent
N 1
• Bad
Intuitive Rules for Entity Sets vs.
Attributes
• Make an entity set only if it either:
1. Is more than a name of something; i.e., it
has nonkey attributes or relationships with
a number of different entity sets, or
2. Is the “many” in a many-one relationship
Example
N 1
Employee Name
SSN
Vehicle
NoOfPassengers d NoOfAxles
Tonnage
MaxSpeed Car Truck
Inheritance
• An entity cannot merely exist by being a
member of a subclass but no superclass;
however, it is not necessary that every entity
in a superclass be a member of some
subclass
• An entity of subclass inherits
– all attributes of superclass
– all relationships in which superclass participates
– plus its own specific attributes and relationships
Specialization
• Why specialization
– Define a set of subclasses of an entity set
– Associate additional specific attributes with each
subclass
– Establish additional specific relationship sets
between each subclass and other entity sets
• Types of specialization
– Predicate-defined: Entities will become members of
a subclass by satisfying explicit condition or
predicate
• Can automatically handled by the system
– User defined
Generalization
Constraints of Specialization and
Generalization
• Disjointness
– Disjoint: An entity can be a member of at most one of the
subclasses
– Overlap: When sub-classes are not disjoint
• Completeness
– Total: Every entity in super class must be a member of some
subclass
– Partial: An entity might not belong to any subclass
• 4 Possible constraints on specialization
– Disjoint, total
– Disjoint, partial
– Overlapping, total
– Overlapping, partial
Hierarchies and Lattices
• Tree-structured (hierarchy): All subclasses have
only one parent
• Graph-structured (lattice): A subclass may have
multiple superclasses
– Engineering_Manager inherits attributes and
relationships from multiple superclasses
Employee
d
d
Secretary Engineer
Technician Hourly Employee
Manager
Salaried Employee
Engineering_Manager
Multiple Inheritance
• Potential ambiguity: If same attributes can be
inherited from more than one superclass
• Bank employee: Instead of defining attribute
salary for superclass employee, we define
attribute pay for each of full-time, part-time,
teller, and secretary as follows:
– Full-time: pay (0-100k)
– Part-time: pay (0-30/hr)
– Teller: pay (0-30k)
– Secretary: pay (0-35k)
Bank Employee Example
Employee
Secretary
Pay
FullTime PartTime
Teller
Pay
Pay
Pay
FullTime-Secretary
Solutions
• Keep all and use alias: fulltime.pay and
secretary.pay
• Choose one based on implementation
• Force user to choose
• Error report
No Ambiguity
• If salary attribute is retained in only one
superclass Employee – all subclasses share
the same definition of salary
• An attribute originating in the same
superclass is inherited more than once via
different paths
– Attribute should be included only once in
subclasses
EER
Name Address
SSN Person Birth-date
o Major-Dept
Salary Student
Degrees Alumnus
Employee
d
d Year Major
Degree
Faculty Under-Grad-
Student- Graduate- Student
Staff Assistant
Rank Student
d Class
Project Degree-Prog