214 Lecture 5
214 Lecture 5
ng
CSC 214
LECTURE 5
1
Lecture Outline
Enhanced E-R Model
– Entity subtypes
– Basic Notation of supertype and subtype relationship
– Specialization and Generalization
– Subtype Discriminator
2
Lecture Objectives
3
Motivation
Supertypes and subtypes occur frequently in the real world,
– e.g food order types (eat in, to go)
– grocery bag types (paper, plastic)
– payment types (check, cash, credit)
You can typically associate „choices‟ of something with supertypes and
subtypes.
– e.g, what will be the method of payment – cash, check or credit card?
Understanding real world examples helps us understand how and when to
model them.
ANIMAL SUPERTYPE
8/20/2018 8 lecture notes
Adapted from Oracle
Supertype Example
• EXAM is a supertype EXAM
# number
of QUIZ, MIDTERM, * description
and FINAL. * weight
* date
• The subtypes have * grade for
written
several attributes in compo
common.
MIDTERM
• These common • Grade for oral presentation
attributes are listed at FINAL
the supertype level. • Extra points for optional paper
QUIZ
MAMMAL OTHER
INVERTEBRATES
specialized
Relationship in versions of
which only supertype
specialized versions
participate
SUBTYPE 1 SUBTYPE 2 SUBTYPE N
Attributes unique to Attributes unique Attributes unique
subype1 to subype 2 … to subype N
Example
An organization has three basic types of employee: hourly employee, salaried employee
, and contract consultnts. Some of the important attributes for each of these types of
employees are the following:
Hourly employees: EmpNo, EmpName, Address, DateHired, HourlyRate
Salaried employees: EmpNo, EmpName, Address, DateHired, AnnualSalary,
StockOption
Contract consultants: EmpNo, EmpName, Address, DateHired, ContractNo,
BillingRate
EMPLOYEE
EmpNo
EmpName
Address
DateHired
Indicates that
a subtype is a
subset of
supertype
CAR TRUCK
VehicleID MOTORCYCLE
VehicleID
Price VehicleID
Price
EngineDisplacement Price
EngineDisplacement VehicleName EngineDisplacement
VehicleName (Make,Model) VehicleName
(Make,Model) Capacity
(Make,Model)
NumOfPersangers CabType
VEHICLE
VehicleID
Price
EngineDisplacemen
Generalization
to VEHICLE t
VehicleName
Supertype
(Make,Model)
CAR TRUCK
NumOfPersanger Capacity
s CabType
Specialization
This is a process of defining one or more subtypes of the supertype
and forming supertype/subtype relationships
This is a top-down process, the direct reverse of generalization.
Example: Business rules observation
There 2 possible sources for parts; some
are manufactured internally, whereas PART
others are purchased from outside PartNo
Description
suppliers.
CityOnHired
It was also observed that some are Location
Routine_number
obtained from both source. {Supplier
The choice depends on the company (SuplierId, UnitPrice)}
manufacturing capacity, unit price of the
parts, and so on.
Some of the attributes apply to all parts
regardless of the source.
RoutineNo, is only associated with parts
that is manufactured internally.
Also, the supplier and unit price attributes PART
are only associated with those parts that are PartNo
purchased outside Description
So this could be resolve in this way. QtyOnHand
Location
Supplier is multivalued and composite
because there may be more than one Routine_number
supplier with an associated unit price for {Supplier(SuplierId, UnitPrice)}
apart.
Example of specialization
Specialization to manufactured
PART part and purchased part
PartNo
Description SUPPLIER
QtyOnHand SuplierId
Location
SUPPLI
MANUFACTURED
PURCHASED ES
PART
PART UnitPric
Routine_number
e
Constraints on supertype and subtype relationship
if it is a member of
Allowed not to It can be …
Must be ... one type, it can not
belong to any ...
simultaneously be
Total Partial of any other … Overlap Rule
specialization specialization
Rule Rule
Disjont Rule
Total Specialization
rule PATIENT
PatientID IsCaredF RESPONSIBLE
PatientName or PHYSICIAN
AdmitDate PhysicianID
RESIDENT
OUTPATIENT BED
PATIENT IsAssigne
CheckbackDate BedID
DateDischarge d
VEHICLE
Partial Specialization VehicleID
Price
rule EngineDisplacem
ent
VehicleName
(Make,Model)
CAR TRUCK
NumOfPersang Capacity
ers CabType
Disjoint
rule PATIENT
PatientID IsCaredF RESPONSIBLE
PatientName or PHYSICIAN
AdmitDate PhysicianID
RESIDENT
OUTPATIENT BED
PATIENT IsAssigne
CheckbackDate BedID
DateDischarge d
Overlap PART
PartNo
rule Description SUPPLIER
CityOnHired SuplierId
Location
Routine_number
MANUFACTURED SUPPLI
PURCHASED ES
PART
PART UnitPric
Routine_number
e
Subtype Discriminator
d
“H” “C”
“S”
HOURLY SALARIED CONTRACT
EMPLOYEES EMPLOYEES CONSULTANTS
HourlyRate AnnualSalary, ContractNo
StockOption BillingRate
PART
PartNo
Description
CityOnHired SUPPLIER
Location SuplierId
Introducing a Routine_number
subtype PartType(Manufactured?, Purchased?)
discriminator
(Overlap rule) PartType =
o
Manufactured? “y” Purchased“y”
MANUFACTURED SUPPLIE
PURCHASED S
PART
PART UnitPric
Routine_number
e
Class Activity 1
A hierarchical arrangement of supertypes and subtypes, where each subtype has only one supertype.
Suppose you are asked to model the human resources in a university. Using specialization (a to-down
approach) where the root general entity type is PERSON with attributes SSN (identifier), Name,
Address, Gender and DOB. There are three types of persons that are of interest to the university which
are: EMPLOYEE (persons who work for the university), STUDENT (persons who attend classes), and
ALUMNUS(persons who have graduated).In this university a person might belong to more than one
categories. Each employee has a value for Date hired and Salary and Student‟s Major department is
recorded. For each ALUMNI the graduating degree is determined by year of graduation, designation and
date of graduation. These two types of EMPLOYEE; FAULTY and STAFF have the following specific
attribute respectively: Rank and Position. Also, a STUDENT could either be GRADUATE student with
Test score or UNDERGRADUATE student with Class standing.
Class Activity 2
Add subtype
discriminator notation,
create a new attribute
for the discriminator if
necessary.
35
Class Activity 3
Rehoboth housing has branch offices in various part of the country. The requirement specification for the company is stated
below.
Each branch office is allocated members of staff and a manager to manage the operations of the office. The information to be
held on the branch office includes a unique branch number, address (street, area ,city), telephone number and the name of the
manager. A staff can only be allowed to manage a branch. There are special staff positions like manager, secretary and sales
personnel. A staff can belong to more than one of the special positions. For each manager there is bonus, each secretary is
characterized by typing speed and each sales rep. has sales area and car allowance A member of staff can either be on part-time
(temporary staff) or full-time (permanent staff) depending on their appointment. Each full time staff is characterized by salary
scale and hourly allowance, while the part- time staff are rated per hour The information stored on each member of staff
includes staff number, name (first and last name), address, telephone number, sex, date of birth, position, salary and date of
appointment. A staff number is unique across all branches of the company. When possible the details of the next-of-kin of staff
members are stored. The information stored on each next-of-kin includes name, relationship to the member of staff, address
and telephone number. Only the detail of one a single next-of-kin are held for a member of staff, and one next-of-kin cannot
stand-in for more than two staff.
(i) Identify the entities and their attributes
(iii) Draw an enhanced Entity relationship model for the requirement specification to reflect the
cardinality and participation constraints, entity attributes, specialization, weak entity.
36
Exercises
1. For a library, the entity type HOLDING has four subtype: BOOK, AUDIO BOOK,DVD and SOFTWARE. Draw a separate
EER diagram segment for each of the following situations:
– At each given time, a holding must be exactly one of these subtypes
– A holding may or may not be one of these subtypes. However, a holding that is one of these subtypes cannot at the same time be one of
the other subtypes
– A holding may or may not be one of these subtypes. On the other hand, a holding may be any two (or even four) of these subtypes at
the same time.
– At a given time, a holding must be at least one of these subtypes
2. At a weekend retreat, the entity type PERSON has three subtypes: CAMPER, BIKER, and RUNNER. Draw a separate EER
diagram segment for each of the following situations: (6marks)
– At a given time, a person must be exactly one of these subtypes.
– A person may or may not be one of these subtypes. However,a person who is one of these subtypes cannot at the same time be one of the other subtypes.
– A person may or may not be one of these subtypes. On the other hand, a person may be any two ( or even three f these subtypes at the same time.
– At a given time, a person must be at least one of these subtype
37
Lecture Reference
Ramakrishnan, R., Gehrke, J.: Database Management Systems. USA: McGraw Hill
Companies (2000)
Elmasri, R., & Navathe, S. (2000). Fundamentals of database systems (3rd ed.). Reading,
Mass.: Addison-Wesley.
Hoffer, J. A., Prescott, M. B., & McFadden, F. R. (2005). Modern database management.
Upper Saddle River, N.J: Pearson/ Prentice Hall.
Connolly, T. M., & Begg, C. E. (2002). Database systems: A practical approach to
design, implementation, and management. Harlow, England: Addison-Wesley
http://pages.cs.wisc.edu/~dbbook/openAccess/thirdEdition/solutions/ans3ed-
oddonly.pdf
https://gyires.inf.unideb.hu/GyBITT/03/
38