Solutions Manual
Chapter 10
Section 10.1
Exercise 10.1.1
(a) SELECT on MovieStar, SELECT on MovieExec.
(b) SELECT on MovieExec, SELECT on Movies, SELECT on StarsIn.
(c) SELECT on Movies, SELECT on Studio, INSERT on Studio (or INSERT(name)
on Studio).
(d) DELETE on StarsIn.
(e) UPDATE on MovieExec (or UPDATE(name) on MovieExec).
(f) REFERENCES on MovieStar (or REFERNCES(gender, name) on MovieS-
tar).
(g) REFERENCES on Studio, REFERENCES on MovieExec (or REFERENCES(name,
presC#) on Studio, REFERENCES(cert#, netWorth) on MovieExec).
2
Exercise 10.1.2
After step (4), the grant diagram is as follows:
A
p
∗∗
-
?
B
p
∗
-
C
p
D
p
∗
-
?
C
p
∗
E
p
∗
After step (5), the grant diagram is as follows:
A
p
∗∗
-
?
B
p
∗
C
p
After step (6), the grant diagram is as follows:
A
p
∗∗
-
B
p
∗
3
Exercise 10.1.3
After step (5), the grant diagram is as follows:
A
p
∗∗
-
?
B
p
∗
-
C
p
∗
-
D
p
∗
E
p
∗
-
:
C
p
After step (6), the grant diagram is as follows:
A
p
∗∗
?
D
p
∗
E
p
∗
-
:
C
p
Exercise 10.1.4
The grant diagram after the final step is as follows:
A
p
∗∗
4
Section 10.2
Exercise 10.2.1
(a) The rules for trips that have reasonable connections are:
Trips(x, y, dep, arr) ← Flights(
, x, y, dep, arr)
Trips(x, y, dep, arr) ← Trips(x, z, dep1, arr1)AND
Trips(z, y, dep2, arr2) AND
arr1 6 dep2 − 100
(b) Using the book’s syntax, the SQL is:
WITH RECURSIVE Trips(frm, to, dep, arr) AS
(SELECT frm, to, dep, arr
FROM Flights )
UNION
(SELECT T.frm, F.to, T.dep, F.arr
FROM Trips T, Flights F
WHERE T.to = F.from
AND T.arr <= F.dep - 100 )
SELECT *
FROM Trips;
Exercise 10.2.2
Because FROM is one of the SQL reserved words, using it as an identifier is not
recommended. Note that most major vendors do not prohibit the use of reserved
words when the use is not ambiguous (e.g. SELECT FROM FROM FROM is not
ambiguous and will work), but such use is highly discouraged for readability and
portability reasons.
5