+ All Categories
Home > Documents > ER-to-Relational Mapping Principles Specialization/Generalization

ER-to-Relational Mapping Principles Specialization/Generalization

Date post: 05-Feb-2016
Category:
Upload: freira
View: 41 times
Download: 0 times
Share this document with a friend
Description:
Outline: ER-to-Relational Mapping Chapter 9 – 3rd ed. (Chap. 7 – 4 th , 5 th ed.; Chap. 9, 6 th ed.). ER-to-Relational Mapping Principles Specialization/Generalization -Superclass/Subclass Relationship. Sec. 9.1, Sec. 4.1 and 4.2. General process - PowerPoint PPT Presentation
22
Jan. 2012 ACS-3902 Yangjun Chen 1 ER-to-Relational Mapping ER-to-Relational Mapping Principles Specialization/Generalization - Superclass/Subclass Relationship Outline: ER-to-Relational Mapping Chapter 9 – 3rd ed. (Chap. 7 – 4 th , 5 th ed.; Chap. 9, 6 th ed.)
Transcript
No Slide TitleOutline: ER-to-Relational Mapping
Chapter 9 – 3rd ed. (Chap. 7 – 4th, 5th ed.; Chap. 9, 6th ed.)
ACS-3902 Yangjun Chen
General process
owner’s PK + partial key becomes PK
3. For each binary 1:1 relationship choose an entity and include the other’s PK in it as an FK. Include any attributes of the relationship
4. For each binary 1:n relationship, choose the n-side entity and include an FK w.r.t the other entity. Include any attributes of the relationship
ACS-3902 Yangjun Chen
ER-to-Relational Mapping
5. For each binary M:N relationship, create a relation for the
relationship
of the relationship
include the PK attributes of the entity type
PK is the PK of the entity type and the multivalued attribute
7. For each n-ary relationship, create a relation for the relationship
include PKs of all participating entities and any attributes of
the relationship
PK may be the concatenation of the participating entity PKs
ACS-3902 Yangjun Chen
include all simple attributes
choose a primary key
ER-to-Relational Mapping
We create a relation for Course - four attributes, course_no is the PK.
course
1
N
include primary key of owner (an FK)
Owner’s PK + partial key become the PK
Suppose we have:
course
1
N
PK is {course_no, section_no}.
course_no is an FK.
meeting is not a simple attribute, so it’s not included.
ACS-3902 Yangjun Chen
ER-to-Relational Mapping
3. For each binary 1:1 relationship choose an entity and include the other’s PK in it as an FK.
There are two choices here
choose department, or
department
instructor
chair
1
1
dept_no
dname
instr_no
iname
ER-to-Relational Mapping
Department is the better choice since it must participate in the relationship.
department
instructor
chair
1
1
dept_no
dname
instr_no
iname
Department
chair
dept_no
dname
If we choose department then instr_no is included as, of course, an FK. Note that instr_no must have a value.
ACS-3902 Yangjun Chen
ER-to-Relational Mapping
4. For each binary 1:n relationship, choose the n-side entity and include an FK w.r.t the other entity.
department
instructor
employs
1
N
dept_no
dname
instr_no
iname
dept_no is an FK
Note that Step 1 would lead to the instructor relation - we have now augmented instructor with the dept_no attribute.
ACS-3902 Yangjun Chen
ER-to-Relational Mapping
5. For each binary M:N relationship, create a relation for the relationship
include PKs of both participating entities and any attributes of the relationship
PK is the catenation of the participating entities’ PKs
student
course
enroll
m
n
grade
Enroll
student_no
Course_no
grade
course_no
student_no
include the PK attributes of the entity type
PK is the PK of the entity type and the multi-valued attribute
course
1
N
ACS-3902 Yangjun Chen
Create a relation for meeting
Section was created because of Step 2 - its PK is {course_no, section_no}
meeting
Meeting
course_no
section_no
meeting
ACS-3902 Yangjun Chen
ER-to-Relational Mapping
7. For each n-ary relationship, create a relation for the relationship
include PKs of all participating entities and any attributes of the relationship
PK may be the catenation of the participating entity PKs (depends on cardinalities)
semester
course
offers
m
n
room
course_no
semester_no
instructor
instr_no
p
ER-to-Relational Mapping
We need one relation, offers, with PK of {semester_no, course_no, instr_no}
semester
course
offers
m
n
Consider Section 4.2 on Specialization and Generalization
Specialization is the process of defining a set of sub-entities of some entity type. Generalization is the opposite approach/process of determining a supertype based on certain entities having common characteristics.
e.g. employees may be paid by the hour or a salary (part vs full-time)
e.g. students may be part-time or full-time; graduate or undergraduate
these are similar to 1:1 relationships, but they always involve entities of one (super)type
these are ‘is-a’ relationships
The arc implies graduate and undergraduate are subtypes of student
The bubble and the d imply disjoint subtypes
(o - overlap subtypes)
Participation of subtype is always mandatory
Subtypes may be disjoint or overlapping
a predicate (on an attribute) determines the subtype: e.g. attribute Student_class
Student_class = ‘graduate’; Student_class = ‘undergraduate’
ACS-3902 Yangjun Chen
4 choices:
1. Create separate relations for the supertype and each of the subtypes.
2. Create relations for the subtypes only - each contains attributes from the supertype.
3. (disjoint subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one discriminator attribute.
4. (overlapping subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one logical discriminator attribute per subtype.
PK is always the same - determined from the supertype
ACS-3902 Yangjun Chen
TECHNICIAN
name
lname
minit
fname
Ssn
bDates
Address
JobType
TypingSpeed
TGrade
EngType
EMPLOYEE
VehicleId
Price
LicensePlate
TNoOfPassengers
NoOfAxles
CAR
TRUCK
MaxSpeed
Tonnage
Vehicle
TECHNICIAN
name
lname
minit
fname
Ssn
bDates
Address
JobType
TypingSpeed
TGrade
EngType
fname, minit, lname, ssn, bdate, address, JobType, TypingSpeed, Tgrade, EngType
EMPLOYEE
EMPLOYEE
PartNo
Description
manufactureDate
Supplier
Part
BatchNo
DrawingNo
ListPrice

Recommended