Professional Documents
Culture Documents
Modeling
Basic concept:
Subset/Superset
• Examples:
– Some Employees are Hourly
– Some Employees are Managers
– All Employees are either technical,
clerical, or managerial
– All employees are either Hourly or
Salaried
1
Why is this Important?
• Subsets may have different
attributes:
– tech employee has SPECIALTY
– Hourly employee has OVERTIME
• Subsets may participate in different
relationships:
– managerial employee manages unit
– hourly employee belongs to a union
Department
Bonus
MANAGES
2
ISA = Inheritance
• MANAGER gets all attribs of
EMPLOYEE
• can participate in all relations
EMPLOYEE participates in.
• this is called INHERITANCE:
• every MANAGER is also an
EMPLOYEE.
• All of this is idea of "ISA" or
"Superclass/Subclass"
2001 Irwin Levinstein
©
3
Specializing Employee
EMPLOYEE Single line: some may be
d: employee "none of the above"
cannot be both
clerical and double line: EVERY employee
d
technical. must belong to one
o: can be
both
Can
Can’t d o belong to
belong to both
more than
one
Technical Contractor
2001 Irwin Levinstein
©
4
Kinds Of Specialization
• Condition (Predicate) defined involves
several attributes
– EX: (Job_type=‘Managerial’ and Salary >
100K ⇒ ‘Upper_Managerial’ subclass)
• Attribute Defined: only one Attribute
involved ⇒ ‘Clerical’ subclass)
– EX: (Job_type in (‘Secretary,
Receptionist, Clerk)
• User Defined
– User places entity in subclass when
entity is created
2001 Irwin Levinstein
©
Generalization
• Build Up Superclass from SubClasses
• Diagram Looks the same as in
Specialization
• Process goes in reverse direction
5
Generalization
• Ex: Company buys Steel and Paper Mills and
merges Databases
• Attributes of FACTORY: INTERSECTION
of attributes of the Subclasses.
FACTORY
Specialization Lattice
• Overlapping Specialization
• Specializations of Specializations
• Multiple Inheritance
6
Lattice Example
• Student graduates and so is Alumnus
• Returns to School and so is a Student
too
• Gets TA position and so is an
Employee
Lattice Person
Example
o
Grad Asst
2001 Irwin Levinstein
©
7
Converting an EER-Diagram
To a Relational Schema
C 3. Avoid Nulls
G
D
H
E F
8
Solution 1: Super/Sub tables
KEY A B BASE
KEY A B
BASE Join on FK
to get all Sub1
d attribs KEY C D
C G
D Sub2
E F H
KEY E F
Sub1 Sub2 Sub3
Sub3
No way to enforce Disjoint
KEY G H
provision
KEY A B Sub2
KEY A B E F
BASE
Sub3
KEY A B G H
d
C G Still cannot enforce
D disjoint requirement
E F H
9
Solution 3: One big table
BASE
KEY A B KEY A B Type C D E F G H
123 aa bb Sub1 cc dd ∅ ∅ ∅ ∅
BASE
234 a2Type
b2 Sub2
says which ∅ ee each
∅ fields ff row
∅ will
∅
345 a3have
b3 Sub3 ∅ ∅ ∅ ∅ gg hh
d 456 a4 b4 sub2 ∅ ∅ e1 f1 ∅ ∅
C G
Disjoint constraint
D
E F H enforced by PK
Summary
• 3 Solutions
– super/sub tables
– subtables only
– one big table
• None is perfect
• Part of reason for development of
Object Relational Databases
10