Chapter 04-2 Supertypes - Subtypes
Chapter 04-2 Supertypes - Subtypes
Chapter 04
• Subtype: A subgrouping of
entities within a supertype
entity
Examples of Supertypes and Subtypes
• PAYMENT entity (check, cash, credit card)
5
Supertypes and Subtypes
6
College Supertype/Subtype Example
• Create an ER diagram to store data about people at a college
• Assumptions:
– A student may have only one major
– Store only the highest degree earned by a faculty member
– The status column of staff members refers to whether they are part-
time or full-time
– The database will not store data about any other category of people
– A person can belong to more than one group at a time
7
College Supertype/Subtype Example
8
Step 1: Identify entities
9
Step 2: Identify attributes and UID
10
Step 3: Identify common attributes
11
Step 4: Create Supertype/Subtype Hierarchy
12
Box-in-Box Presentation
13
Non-Box-in-Box Presentation
14
Inheritance - attributes
• Subtype entities inherit all
attributes of the supertype
20
Exclusive or Non-Overlapping Subtype Rule
• Each supertype instance can be
related to only one subtype
instance
22
Mutually Exclusive
• A vehicle is "classified" into subtypes
• Mutually Exclusive: every instance of VEHICLE must be an
instance of only ONE of the subtypes
23
Nested Subtypes
• Subtypes can be nested
24
Supertypes and Subtypes
• A subtype:
– inherits all attributes of the supertype
– inherits all relationships of the supertype
– have attributes or relationships that are different from other subtypes
– is drawn within the supertype
– never exists alone
– may have subtypes of its own
25
Supertypes and Subtypes
• Each subtype has an attribute that the other subtypes may not
have, and can't go in the supertype because all of them don't
"need" that attribute
• If an entity has a subtype, there should always be at least a
second subtype
26
Example
• Both outpatients and resident patients are cared for by a
physician
• Only resident patients are assigned to a bed
27
The End
28
Business Rules
• One of the primary goals of data modeling is to ensure that all
pieces of information that are required to run a business are
recognized
29
Business Rules
• Structural rules indicate
– The type of data to be stored (attributes)
– How the data elements interrelate (relationships)
– Rules implemented in an ERD
• Procedural rules indicate
– Workflow processes
– Business processes
– Rules implemented by programming
30
Structural or Procedural Rule?
• All teachers must possess a valid teaching certificate
• Structural
– Type of data to be stored (attribute)
31
Structural or Procedural Rule?
• All orders at a restaurant must be handled by staff. There is no
self-service ordering system
• Structural Rule
– How the data elements interrelate (relationships)
32
Procedural Rule
• Students must have studied algebra and geometry in order to
sign up for trigonometry
– Could you represent this in the ERD?
No
– How would you implement this with programming?
When a student tries to sign up for a class, a program checks to see if the
student has taken the pre-requisite
33
Procedural Rule
– If the student had taken the pre-requisite(s), what is another business
rule that a school may want in this scenario?
Did the student pass the pre-requisite(s)
34
Documenting Procedural Rules
• In the process of developing a conceptual data model, not all
business rules can be modeled
• Some rules must be implemented by programming:
– Any employee whose overtime exceeds 10 hours per week must be
paid 1.5 times the hourly rate
35
Inclusive or Overlapping Subtype Rule
• A supertype instance may belong to more than one subtype
category
• In the example, Dana Hewitt is both a STUDENT and STAFF
36
The End
37