Sie sind auf Seite 1von 19

# CGS 2545 Database Concepts (Chapter 4 Exercises) Page 1 Dr.

Mark Llewellyn
CGS 2545: Database Concepts
Spring 2012

Chapter 4 In-class Exercises
School of Electrical Engineering and Computer Science
Computer Science Division
University of Central Florida
Instructor : Dr. Mark Llewellyn
markl@cs.ucf.edu
HEC 236, 407-823-2790
http://www.cs.ucf.edu/courses/cgs2545/spr2012
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 2 Dr. Mark Llewellyn

Transform each of the ER diagrams shown on this and the
following few pages, into a set of relational schemas which
show referential integrity constraints.
Introduction
Problem #1
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 3 Dr. Mark Llewellyn

Solution for Problem #1
Employee_ID Skill
EMPLOYEE SKILL
EMPLOYEE
Multi-valued attribute
is contained in a
separate table.
Derived attribute is
replaced with the attribute
actually maintained in the
database. Transformation
technique is not indicated
at this level.
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 4 Dr. Mark Llewellyn

Problem #2
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 5 Dr. Mark Llewellyn

Solution for Problem #2
Flight_Number Date Number_of_Passengers
FLIGHT
Composite attribute Flight_ID is replaced
by both of the sub-component attributes of
the original composite attribute. Note that
since the original composite attribute was
a key attribute that all of the sub-
component attributes are now key
attributes.
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 6 Dr. Mark Llewellyn

Problem #3
Date_Completed
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 7 Dr. Mark Llewellyn

Solution for Problem #3
EMPLOYEE
Employee_ID Course_ID Date_Completed
COMPLETION
COURSE
Course_ID Course_Title
The M:M relationship
is modeled as a table.
Course_ID
Employee_LastName Employee_FirstName Employee_ID
Topic
The multi-valued
attribute is modeled in
its own table.
Birth_Date
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 8 Dr. Mark Llewellyn

Problem #4
Note that this is the same problem as #3,
however, this time the relationship has been
modeled with an attribute and as an
associative entity rather than as a simple
M:M binary relationship.
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 9 Dr. Mark Llewellyn

Solution for Problem #4
When the certificate is modeled as an
associative entity and has an identifier (in
this case the certificate number), that
identifier becomes the key of the relation
scheme with the identifiers in the two
participating entity sets becoming foreign
keys in the associative entity table.
EMPLOYEE
Certificate_ID Employee_ID Course_ID
COMPLETION
COURSE
Course_ID Course_Title
Course_ID
Employee_LastName Employee_FirstName Employee_ID
Topic
Date_Completed
Birth_Date
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 10 Dr. Mark Llewellyn

Problem #5
Basic 1:M binary relationship.
MOVIE
Movie_Name
Star
Year_Produced
DVD
Copy_Number
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 11 Dr. Mark Llewellyn

Solution for Problem #5
Movie_Name
MOVIE
Copy_Number Movie_Name
DVD
Star Year_Produced
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 12 Dr. Mark Llewellyn

Problem #6
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 13 Dr. Mark Llewellyn

Solution for Problem #6
Assuming disjoint constraint

Vehicle_ID Price Make Model Engine_Displacement
VEHICLE
C_Vehicle_ID No_of_Passengers
CAR
T_Vehicle_ID Cab_Type Capacity
TRUCK
Vehicle_type
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 14 Dr. Mark Llewellyn

Solution for Problem #6
Assuming overlapping constraint

Vehicle_ID Price Make Model Engine_Displacement
VEHICLE
C_Vehicle_ID No_of_Passengers
CAR
T_Vehicle_ID Cab_Type Capacity
TRUCK
Car ? Truck ?
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 15 Dr. Mark Llewellyn

Problem #7
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 16 Dr. Mark Llewellyn

Solution for Problem #7
Assuming disjoint constraint
RESPONSIBLE PHYSICIAN
O_Patient_ID Checkback_Date
PATIENT
Bed_ID
Physician_ID
Physician_ID

OUTPATIENT
RESIDENT PATIENT
R_Patient_ID Date_Discharged
Bed_ID
BED
Patient_type
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 17 Dr. Mark Llewellyn

Solution for Problem #7
Assuming overlapping constraint
RESPONSIBLE PHYSICIAN
O_Patient_ID Checkback_Date
PATIENT
Bed_ID
Physician_ID
Physician_ID

OUTPATIENT
RESIDENT PATIENT
R_Patient_ID Date_Discharged
Bed_ID
BED
out_patient ? resident_patient ?
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 18 Dr. Mark Llewellyn

Problem #8
CGS 2545 Database Concepts (Chapter 4 Exercises) Page 19 Dr. Mark Llewellyn

Solution for Problem #8
Assuming Overlapping constraint
PART
Part_No
PURCHASED PART
M_Part_No.
MANUFACTURED PART
Description Location Manufactured ? Purchased ? Quantity_on_Hand
P_Part_No.
P_Part_No.
SUPPLY LINE
Supplier_ID Unit_Price
SUPPLIER
Supplier_ID Supplier_Name
Routing_Number