0% found this document useful (0 votes)
45 views38 pages

214 Lecture 5

The document discusses the enhanced entity-relationship (EER) model and how to model supertype and subtype relationships. It introduces the concepts of generalization and specialization using examples like different types of payments, animals, and employees. Key points covered include attribute inheritance in subtypes, always having more than one subtype, and nested subtype relationships. Generalization is defined as a bottom-up process of defining a more general entity type from specialized types.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views38 pages

214 Lecture 5

The document discusses the enhanced entity-relationship (EER) model and how to model supertype and subtype relationships. It introduces the concepts of generalization and specialization using examples like different types of payments, animals, and employees. Key points covered include attribute inheritance in subtypes, always having more than one subtype, and nested subtype relationships. Generalization is defined as a bottom-up process of defining a more general entity type from specialized types.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

www.covenantuniversity.edu.

ng

Database Design and Management

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

 At the end of this lecture,


– The fundamental concepts of the Enhanced E-R (EER) conceptual model
should be fully understood.
– There should be a good understanding of how to model problems cases
and scenarios using the EER Model.

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.

8/20/2018 4 lecture notes


Adapted from Oracle
Evaluating Entities
• Often some instances of an entity
have attributes and/or relationships PAYMENT
that other instances do not have.
CASH
• Imagine a business which needs to cheque
track payments from customers. CHEQUE

• Customers can pay by cash, by CREDIT CARD


check, or by credit card.
8/20/2018 5 lecture notes
Adapted from Oracle
Evaluating Entities
• All payments have some common
attributes: payment date, payment PAYMENT
amount, and so on. CASH
• But only credit cards would have a “card
number” attribute. cheque
CHEQUE
• And for credit card and check
payments, we may need to know which
CREDIT CARD
CUSTOMER made the payment, while
this is not needed for cash payments.
8/20/2018 6 lecture notes
Adapted from Oracle
Subdivide an Entity
• Sometimes it makes sense to subdivide an
entity into subtypes.
• This may be the case when a group of ANIMAL
instances has special properties, such as VERTEBRATE
attributes or relationships that exist only
for that group.
• In this case, the entity is called a INVERTEBRATE
“supertype” and each group is called a
“subtype”.
ANIMAL SUPERTYPE
8/20/2018 7 lecture notes
Adapted from Oracle
Subtype Characteristics
• A subtype: Inherits all attributes of the
supertype
• Inherits all relationships of the supertype ANIMAL
• Usually has its own attributes or VERTEBRATE
relationships
• Is drawn within the supertype
INVERTEBRATE
• Never exists alone
• May have subtypes of its own

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

8/20/2018 9 lecture notes


Adapted from Oracle
Always More Than One Subtype
 When an ER model is complete, subtypes never stand alone. In other
words, if an entity has a subtype, a second subtype must also exist. This
makes sense.

 A single subtype is exactly the same as the supertype.

8/20/2018 10 lecture notes


Adapted from Oracle
Nested Subtypes
• You can nest subtypes. ANIMAL
• For ease of reading –
VERTEBRATE
“readability” -- subtypes are usually shown with
only two levels, but there is no rule that would BIRD REPTILE
stop owner from going beyond two levels

MAMMAL OTHER

INVERTEBRATES

NESTED ANIMAL SUPERTYPE


8/20/2018 11 lecture notes
Adapted from Oracle
Basic Notation of supertype and subtype relationship
Relationship in SUPERTYPE
which all instances Attributes share by General
participate entity
all entities (including type
identifier)

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

HOURLY SALARIED CONTRACT


EMPLOYEES EMPLOYEES CONSULTANTS

HourlyRate AnnualSalary, ContractNo


StockOption BillingRate
Attribute inheritance

 A property by which subtype entities inherit values of all attributes of the


supertype.
 A typical example is the Employee Super type and the three subtypes.
 The following attributes are inherited by Hourly employees, Salaried employees
and Contract consultants from Employee entity

employees:EmpNo, EmpName, Address, DateHired


Specialization and Generalization

 These are mental models in developing a supertype/subtype relationships


Generalization

 In data modeling, this is a process of defining a more general entity type


from a set of more specialized entity types.
 Generalization is a buttom –up process.
 Generalization allows grouping of entity types along with common
attributes and at the same time preserve specific attributes that a peculiar
to each entity.
Example: Generalization
Three Entity types
: CAR, TRUCK,
MOTORCYCLE

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

The data modeler initially


planned to associate supplierID
and unit price with
PURCHASED part, however in
further discussion with users,
the data modeler decided to
create a supplier entity.

SUPPLI
MANUFACTURED
PURCHASED ES
PART
PART UnitPric
Routine_number
e
Constraints on supertype and subtype relationship

 Participation /Completeness Constraints


– Total Specialization rules
– Partial Specialization rule
 Disjointness Constraints
– Disjoint rule
– Overlap rule
1 2
Can an instance of a
Must an instance of a supertype simultaneously
supertype be a be a member of two or
member of at least more subtypes?
one subtype?

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

 An attribute of the supertype whose values determine the target subtype of


subtypes.
For example, the condition
EMPLOYEE
“EmployeeType=S” causes an entity EmpNo Introducing a subtype
instance to be inserted into the
EmpName
SALARIED EMPLOYEE subtype. discriminator
Address
DateHired (disjoint rule)
EmployeeType
Total and disjoint
EmployeeType = constraint

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

You might also like