You are on page 1of 10

Enhanced Entity Relationship

Modeling

2001 Irwin Levinstein

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

2001 Irwin Levinstein

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
2001 Irwin Levinstein

MANAGER "IS-A" EMPLOYEE.


Meaning:
Manager

All Emps work for


Departments

EMPLOYEE

Employee

WORKS
FOR

Department
Bonus

MANAGES

MANAGER
Mgrs can get bonuses

But Managers can


also manage them

2001 Irwin Levinstein

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

Specialization and Generalization


Specialization defines SETS of
Subclasses on a Class.
Each SET called a Specialization

Generalization unites several entities


into a Set of Sub-Classes, making a
new class.
Subclasses in a Specialization may be
disjoint or overlap
Entities in class may be total or
partial members of the specialization

2001 Irwin Levinstein

Specializing Employee
d: employee
cannot be both
clerical and
technical.

EMPLOYEE

Single line: some may be


"none of the above"
double line: EVERY employee
must belong to one

o: can be
both

Clerical

Technical

Managerial

This set, CLERICAL, TECHNICAL, and


MANAGERIAL, is a SPECIALIZATION of
EMPLOYEE.
2001 Irwin
Levinstein

More than 1 Specialization


EMPLOYEE

Total
Participation
Cant
belong to
more than
one

Clerical

Partial
Participation
o

Managerial

Technical

Can
belong to
both

Hourly
Contractor

2001 Irwin Levinstein

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

2001 Irwin Levinstein

Generalization
Ex: Company buys Steel and Paper Mills and
merges Databases
Attributes of FACTORY: INTERSECTION
of attributes of the Subclasses.
FACTORY
d

Steel Mill

Paper Mill

2001 Irwin Levinstein

Specialization Lattice
Overlapping Specialization
Specializations of Specializations
Multiple Inheritance

2001 Irwin Levinstein

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

2001 Irwin Levinstein

Lattice
Example

Student

Person
o

Employee

Alumnus

GRAD ASST could be


further specialized
into TA and RA

Grad Asst
2001 Irwin Levinstein

Converting an EER-Diagram
To a Relational Schema

2001 Irwin Levinstein

The Problem
KEY

1. Solution must
associate base
attributes with
specialized attributes
for each object

A
BASE

2. Desirable to enforce
disjoint constraint

d
C
D
Sub1

3. Avoid Nulls

G
E

F
Sub2

Sub3

Base class, 3 subclasses in a specialization.


How to represent in a DB Schema Diagram.
2001 Irwin Levinstein

Solution 1: Super/Sub tables


KEY

BASE
d

B
Join on FK
to get all
attribs

KEY

BASE
A

KEY

Sub1
C

Sub2
E

Sub3
KEY
G

Sub1

Sub2

KEY

Sub3

No way to enforce Disjoint


provision
2001 Irwin Levinstein

Solution 2: Subtables only


Need UNION to retrieve
BASE parts of all objects
KEY

KEY

BASE

KEY

d
C
D

G
E

Sub1

KEY

Sub2

Sub3

Sub1
A B

C D

Sub2
A B

E F

Sub3
A B

G H

Still cannot enforce


disjoint requirement
Only works if
participation mandatory

2001 Irwin Levinstein

Solution 3: One big table


KEY

KEY

BASE
A B Type C D E

123 aa bb Sub1

456 a4 b4 sub2

Sub1

Sub2

f1

cc dd
234 a2Type
b2 Sub2
ff row
will

says which
fields
ee each
345 a3have
b3 Sub3 gg hh

BASE

Sub3

e1

Disjoint constraint
enforced by PK
LOTS of NULLS ()

2001 Irwin Levinstein

Summary
3 Solutions
super/sub tables
subtables only
one big table

None is perfect
Part of reason for development of
Object Relational Databases
2001 Irwin Levinstein

10

You might also like