Professional Documents
Culture Documents
Data Modeling and Database Design 2nd Edition Umanath Solutions Manual 1
Data Modeling and Database Design 2nd Edition Umanath Solutions Manual 1
Chapter 6 Objectives
After completing this chapter, the student will understand:
• The characteristics of a relation
• Data integrity constraints that pertain to the relational data model
• Some basic relational algebra operations
• The role of views and materialized views in the relational data model
• Problems caused by the lack of information preservation in data model mapping
• Two basic (popular) approaches to map ER and EER constructs to a logical schema
• An information-preserving grammar to map ER and EER constructs to a logical schema
• Mapping complex ER models to logical schema
Chapter 6 Overview
This chapter introduces the relational data model and the process of mapping a conceptual
schema that is technology-independent to a logical schema (in this case, a relational data model)
that provides the transition to a technology-dependent database design. The chapter begins with a
discussion of the characteristics of a relation and the data integrity constraints that accompany
the relational data model. This is followed by a brief introduction to relational algebra as a means
to specify the logic for data retrieval from a series of relations. The rest of the chapter discusses
mapping a conceptual schema to its logical counterpart in the context of several examples that
employ both an information-reducing mapping grammar and an information-preserving mapping
grammar.
Data Modeling and Database Design 6-2
Chapter 6 Solutions
2. What is a relation schema? What is the difference between a relation, a relation schema, and
a relational schema?
Answer. A relation schema represents the basic structure of a relation. It consists of a name
along with a set of related attributes. When sets of values are assigned to the attributes that
make up a relation schema, a relation is created. In other words, a relation is a relation
schema with data. The terms “relation” and “relation schema” are typically used
interchangeably. A relational schema is a set of relation schemas. A relational schema is
another name for a relational data model (see footnote 1 at the bottom of page 245).
3. What is the difference between a derived attribute and a stored attribute in terms of their
representation in a relation schema?
Answer. Only stored attributes are captured in a relation schema.
6. What is a candidate key? How does a candidate key differ from a superkey?
Answer. A candidate key is defined as a superkey with no proper subsets that are superkeys.
A candidate key has two properties: the uniqueness property and the irreducibility property,
whereas a superkey possesses only the uniqueness property.
7. What is a primary key? How do the properties of a primary key differ from those of a
candidate key?
Answer. A primary key is a candidate key that in addition to having the uniqueness and
irreducibility properties also satisfies the entity integrity constraint (i.e., a primary key
cannot have a missing value).
Data Modeling and Database Design 6-7
8. Identify the superkeys, candidate key(s), and the primary key for the following relation
instance of the STU-CLASS relation schema.
Answer.
Superkey Candidate Key
Student Number N N
Student Name N N
Student Major N N
Class Name N N
Class Time N N
(Student Number, Student Name) N N
(Student Number, Student Major) N N
(Student Number, Class Name) Y Y
(Student Number, Class Time) Y Y
(Student Name, Student Major) N N
(Student Name, Class Name) N N
(Student Name, Class Time) N N
(Student Major, Class Name) N N
(Student Major, Class Time) N N
(Class Name, Class Time) N N
(Student Number, Student Name, Student Major) N N
(Student Number, Student Name, Class Name) Y N
(Student Number, Student Name, Class Time) Y N
(Student Number, Student Major, Class Name) Y N
(Student Number, Student Major, Class Time) Y N
(Student Number, Class Name, Class Time) Y N
(Student Name, Student Major, Class Name) N N
(Student Name, Student Major, Class Time) N N
(Student Name, Class Name, Class Time) N N
(Student Major, Class Name, Class Time) N N
(Student Number, Student Name, Student Major, Class Name) Y N
(Student Number, Student Name, Student Major, Class Time) Y N
(Student Number, Student Name, Class Name, Class Time) Y N
(Student Number, Student Major, Class Name, Class Time) Y N
(Student Name, Student Major, Class Name, Class Time) N N
(Student Number, Student Name, Student Major, Class Name, Class Time) Y N
Data Modeling and Database Design 6-8
9. Define the term referential integrity constraint. Why is referential integrity important? How
is the term foreign key used in the context of referential integrity?
Answer. Informally, a referential integrity constraint implies that a tuple in a relation, r2,
that refers to another relation, r1, refers to a tuple that exists in r1. In order to establish a
referential integrity constraint between the two relation schemas, R1 and R2, it is necessary
that every value of an attribute A2, atomic or molecular, in relation to r2 must either be null
or occur as the value of a candidate key in some tuple of the relation r1 that r2 refers to.
The attribute in R2 that meets this condition is called a foreign key of R2. R2 is called the
referencing relation schema and R1 is known as the referenced relation schema.
10. This exercise refers to the relations R1 and R2 given below. Show the relations created as a
result of the following relational algebra operations.
Relation R1 Relation R2
R1.a R1.b R1.c R2.x R2.y R2.z
30 a 20 30 b 24
45 b 32 75 c 12
75 a 24 30 b 20
Answer.
10a. The union of R1 and R2
Relation R3 – Result
R3.a R3.b R3.c
30 a 20
45 b 32
75 a 24
30 b 24
75 c 12
30 b 20
10e. The natural join of R1 and R2. Assume that R1.a and R2.x are the joining attributes.
Relation R3 – Result
R3.a R3.b R3.c R3.y R3.z
30 a 20 b 24
30 a 20 b 20
75 a 24 c 12
11. Exercise 11 refers to the DRIVER, TICKET_TYPE, and TICKET relations given below.
An instance of each of these relations follows. Use the data shown below to (a) write the
answer to each question and (b) list the relational algebra operation(s) required to obtain the
answer.
Dr_license_no Dr_name Dr_city Dr_state
MVX 322 E. Mills Waller TX
RVX 287 R. Brooks Bellaire TX
TGY 832 L. Silva Sugarland TX
KEC 654 R. Lence Houston TX
MQA 823 E. Blair Houston TX
GRE 720 H. Newman Pearland TX
Ttp_offense Ttp_fine
Parking 15
Red Light 50
Speeding 65
Failure To Stop 30
Answer.
11a. What are the names of all drivers?
E. Mills, R. Brooks, L. Silva, R. Lence, E. Blair, H. Newman
Requires a projection operation over the DRIVER relation on the Dr_name attribute.
PROJECT DRIVER OVER DRIVER.Dr_name GIVING ANSWER.
11b. What are the license numbers of all drivers who have been issued a ticket?
MVX 322, RVX 287, TGY 832, KEC 654
Requires a projection operation over the TICKET relation on the Tic_dr_license attribute.
PROJECT TICKET OVER TICKET.Tic_dr_license_no GIVING ANSWER.
Data Modeling and Database Design 6-10
11c. What are the license numbers of those drivers who have never been issued a ticket?
MQA 823, GRE 720
Requires taking the difference of projections the driver license number attribute in the DRIVER
and TICKET relations.
PROJECT DRIVER OVER DRIVER.Dr_license_no
MINUS
PROJECT TICKET OVER TICKET.Tic_dr_license_no GIVING ANSWER
11d. What are the names of all drivers who have been issued a ticket?
E. Mills, R. Brooks, L. Silva, R. Lence
Requires joining the DRIVER and TICKET relations over their common attribute driver license
number and then following this with a projection operation that projects out the name of
driver.
JOIN DRIVER AND TICKET OVER DRIVER.Dr_license_no, TICKET.Tic_dr_license_no
GIVING ANSWER
PROJECT ANSWER OVER ANSWER.Dr_name GIVING FINAL_ANSWER
12. What would cause a relational schema for a database to contain more relation schemas than
there are entity types?
Answer. This is somewhat of a trick question. A relational schema has the same number of
relation schemas as there are entity types as long as the Fine-granular Design-Specific ER
diagram serves as input.
14. What is required to map a base entity type to a relation schema? Describe how this approach
differs for a weak entity type.
Answer. Four activities are required: (1) create a relation schema for each base entity type
in the Fine-granular Design-Specific ER diagram, (2) include the stored attributes
associated with the entity type in the relation schema, (3) in the case of composite attributes
record only the atomic components, and (4) underline the atomic attribute(s) that make up
the primary key. A weak entity type is mapped in a like manner except that the primary key of
the identifying parent of the weak entity type is added to the relation schema.
15. What is required to map a relationship type that exhibits a 1:n cardinality ratio?
Answer. Using the foreign key design, place the key (either the primary key or a candidate
key) of the parent as a foreign key attribute of the child.
16. What is the difference between the referencing relation schema and the referenced relation
schema? How are these terms incorporated into the foreign key design?
Answer. The parent is the referenced relation schema and the child is the referencing
relation schema (i.e., it references the relation schema that contains the primary key).
Data Modeling and Database Design 6-11
21. Describe how to map a specialization hierarchy, a specialization lattice, and a categorization.
Answer. Three different logical schema solutions are possible for mapping a specialization.
The first solution is to create one logical scheme for each of the subclasses and superclass in
the specialization. The second solution is the opposite of the first in that one logical scheme
is used to represent the entire specialization. The third solution involves incorporating the
attributes of the superclass in each of the individual logical schemes for the subclasses. It
should be noted that this approach cannot be used if the completeness constraint is partial.
Data Modeling and Database Design 6-12
a. Specialization hierarchy. Add the primary key of the superclass entity type as a foreign
key of the subclass entity type when mapping.
b. Specialization lattice. Add the primary key of each superclass entity type as a foreign key
of the subclass entity type.
c. Categorization. Add the primary key of the subclass entity type to each superclass entity
type.
22. What do you think are the ultimate consequences of failure to “preserve information” in the
data model mapping process?
Answer. Unless a complete mapping of all modeling constructs and constraints that are
inherent, implicit, or explicit in the source (i.e., conceptual) data model occurs in the target
(i.e., logical) data model, they will have to be handled in the logical design activity through
application programs, or the ultimate consequences will be acceptance of an information-
reducing transformation.
23. For the following excerpt from an ERD, specify the logical (relational) schema as per the
foreign key design in the following ways:
a. using directed arcs
b. in terms of inclusion dependencies
[A,1] [N,6]
[A,20] Base_salar
Mini [A,7]
Lnam y
t [N,2] Lic_plate
e
#
[A,20] Pct_commisio
Vin_num
Fname n
Name
[N,5.2]
Emp_no (0, n)
Sells (0, Msrp
1)
SALESPERSON VEHICLE
[A,1]
Gende [N,4]
r Model_y
r [A,13
[Dt,8] ]
Date_hire Make
d
Answer
From the answer to (b) given below, it is easy to draw the single directed arc.
24. List (tabulate) the metadata available in the ER diagram in Exercise 23 on the next page (see
page 301) and indicate the ones captured in the logical (relational) schema of design 23(a)
and design 23(b).
Data Modeling and Database Design 6-13
Answer. The metadata available in the ER diagram in Exercise 23 includes the type and size
of each attribute, whether the attribute is mandatory or optional, and whether the attribute is
a simple or composite specification of all uniqueness constraints, participation constraints,
and cardinality ratio constraints. On the other hand, considerable metadata is lost when
mapping the ER diagram to either of the logical schemas. Metadata lost includes the type
and size of each attribute, whether the attribute is mandatory or optional, all composite
attributes, all alternate keys (e.g., Lic_plate#), the nature of the cardinality ratio, and in the
case of the foreign key design using directed arcs, the nature of the participation constraints.
In the case of the foreign key design using inclusion dependencies, the optional or total
participation of the child is shown.
25. For the ER diagram in Exercise 23, specify the logical (relational) schema as per the cross
referencing design:
a. using directed arcs
b. in terms of inclusion dependencies
From the answer to (b) given below, it is easy to draw the two directed arcs.
Also, explain the merits and demerits of this cross-referencing design over the foreign key
design solution.
Answer. The cross-referencing design guarantees absence of null values that would
otherwise appear in the VEHICLE relation had the foreign key design been used and vehicles
not sold by a salesperson existed. Strict use of the cross-referencing design necessitates the
creation of a separate relation in situations where partial participation exists, thus
increasing the number of relations in the database.
Name
PROGRAMMER SYSTEM
Gender
Date_hired
Data Modeling and Database Design 6-14
For the following three cases, specify the logical (relational) schema using either directed
arcs or in terms of inclusion dependencies according to the foreign key design, cross-
referencing design and mutual-referencing design:
a. when x = 0 and y = 1
b. when x = 0 and y = 0
c. when x = 1 and y = 1
In each case, offer a comparative discussion of the merits and demerits of the three design
options.
Answer.
Exercise 26 - Part a.
Foreign Key Design
Cross-referencing Design
Mutual-referencing Design
PROGRAMMER (Pr_empno, Pr_name, Pr_gender, Pr_date_hired, Pr_qualification, Pr_salary, Pr_sys_sys_id)
Exercise 26 - Part b
Foreign Key Design
Cross-referencing Design
Mutual-referencing Design
Exercise 26 - Part c
Mutual-referencing Design
PROGRAMMER (Pr_empno, Pr_name, Pr_gender, Pr_date_hired, Pr_qualification, Pr_salary, Pr_sys_sys_id)
Salary
Qualification Gender Date_hired
Name
Emp_no
(x, 1)
NURSE
Supervises
Specify the logical (relational) schema (choosing a design without a need to use null values
to indicate partial participation) in the following ways:
a. using directed arcs
b. in terms of inclusion dependencies
From the answer to (b) given below, it is easy to draw the single directed arc.
28. How can the design requirement in Exercise 27 above be satisfied if the “Supervisee” part of
the relationship has the structural constraints (0, 1)? Again, show a design using both directed
arcs and in terms of inclusion dependencies.
From the answer to (b) given below, it is easy to draw the two directed arcs.
29. Specify the logical schema for the ER diagram shown in Exercise 23 using the information-
preserving grammar, and indicate the metadata present in the ER diagram (Exercise 24)
captured by this logical schema.
Answer.
∙ ∙ ∙ ∙
L1: SALESPERSON (Sls_empno , [Sls_fname, Sls_minit, Sls_lname], Sls_pctcommission, Sls-basesalary , Sls_gender , Sls_datehired )
(N,5) (A,20) (A,1) (A,20) (N,2) (N,6) (A,1) (Dt,8)
0 <---------------------L1--------------------- > n
∙ ∙ ∙ ∙
L2: VEHICLE (Veh_vinnum, Q[Veh_licplate# ], Veh_msrp , Veh_model_yr , Veh_make , [Veh_sls_fname, Veh_sls_minit, Veh_sls_lname])
(A,30) (A,7) (N,5.2) (N,4) (A,13) (A,20) (A,1) (A,20)
0 <----------------------R----------------------> 1
30. Specify the logical schema for the ER diagram shown in Exercise 27 using the information-
preserving grammar.
Answer.
0 <-----L1------n>
∙ ∙ ∙ ∙
L1: NURSE (Nur_empno, Nur_name , Nur_qualification, Nur_salary , Nur_gender , Nur_date_hired , Nur_nur_empno)
(N,5) (A,30) (A,1) (N,6) (A,1) (Dt,8) (N,5)
1 <------D------1>
Since attribute type and size are not provided in the ER diagram, those given are assumed values. Likewise, since every nurse must have a
supervisor, the Set Default deletion rule was assumed to apply should the supervisor of a nurse be deleted.
(0,n) (1,1)
MEDICATION Listed_i PRESCRIPTION_
n ORDER
List_price
Data Modeling and Database Design 6-17
Using the foreign key design, specify the logical schema for this diagram in the following
ways:
a. with a directed arc
b. in terms of an inclusion dependency
c. using the information-preserving grammar.
From the answer to (b) given below, it is easy to draw the single directed arc.
0 <------L1-------n>
∙
L2: PRESCRIPTION_ORDER (Pod_med_med_code, Pod_prescription#, Pod_date )
(A,3) (X,10) (Dt,8)
1 <-------R--------1>
Year Quarter
COMPANY
STUDENT
Location Period
Stipend
1 1
INTERNSHIP n
m
Provides Gets
Using the foreign key design, specify the logical schema in the following ways:
Also, list the metadata present in the ER diagram and indicate the ones captured by each of
the three designs of the logical schema.
From the answer to (b) given below, it is easy to draw the two directed arcs.
1<--L1---m> 0---L2---n>
L3: INTERNSHIP (Int_cmp_name, Int_stu_name, Int_location, Int_stipend, [Int_year, Int_quarter])
(A,30) (A,30) (A,20) (N,5) (N,4) (A,2)
1<--C---1> 0----C----1>
33. Specify the logical (relational) schema for the ER diagram shown in Figure 5-61 in Chapter 5
for the Cougar Medical Associates as per the foreign key design:
a. using directed arcs
b. in terms of inclusion dependencies
Answer.
The very purpose this question is to demonstrate how impractical it is to use the directed
arc technique for specifying the logical schema for a real-world type of a large ER model.