3.7
Consider the SQL query
SELECT p.a1
FROM p, r1, r2
WHERE p.a1 = r1.a1 OR p.a1 = r2.a1
Under what conditions does the preceding query select values of p.a1 that are either in r1 or in r2 ? Examine carefully the cases where either r1 or r2 may be empty.
The query selects those values of p.a1 that are equal to some value of r1.a1 or r2.a1 if and only if both r1 and r2 are non-empty. If one or both of r1 and r2 are empty, the Cartesian product of p, r1 and r2 is empty, hence the result of the query is empty. If p itself is empty, the result is empty.