|
|
Q1: select V from T where V >= all (select V from T) Q2: select V from T as T1 where V > all (select V from T as T2 where T2.K <> T1.K) Q3: select max(V) from T
(a) Are Q1 and Q2 equivalent? That is, are they guaranteed to produce the same result on every possible instance of table T? If not, show the smallest instance of T you can find for which Q1 and Q2 produce different results. (Note: All three queries produce an empty result on an empty table.)
(b) Same as part (a), except consider equivalence of queries Q2 and Q3.
(c) Same as part (a), except consider equivalence of queries
Q1 and Q3.
(R1 JOIN R2) JOIN R3 and R1 JOIN (R2 JOIN R3)always produces the same final result.
(a) Is the natural-left-outerjoin operator associative? If so, briefly argue why. If not, show the simplest example you can find where:
(R1 NATURAL-LEFT-OUTERJOIN R2) NATURAL-LEFT-OUTERJOIN R3 and R1 NATURAL-LEFT-OUTERJOIN (R2 NATURAL-LEFT-OUTERJOIN R3)produce a different final result.
(b) Is the natural-full-outerjoin operator associative? If so, briefly argue why. If not, show the simplest example you can find where:
(R1 NATURAL-FULL-OUTERJOIN R2) NATURAL-FULL-OUTERJOIN R3 and R1 NATURAL-FULL-OUTERJOIN (R2 NATURAL-FULL-OUTERJOIN R3)produce a different final result.