Let R(P,Q,R1,R2,R3) and S(P,Q,S1,S2) be two relations with {P,Q} as the key for both schemas. Which of the following queries are equivalent?
I. Π_P (R⋈S) II. Π_P(R) ⋈ Π_P(S) III. Π_P (Π_{P,Q}(R) ∩ Π_{P,Q}(S)) IV. Π_P (Π_{P,Q}(R) − (Π_{P,Q}(R) − Π_{P,Q}(S)))
- AOnly I and II
- BOnly I and III
- COnly I, II and III
- Only I, III and IV
Explanation
By the set identity A−(A−B)=A∩B, IV simplifies to exactly III. Since {P,Q} is a key for both relations, the natural join R⋈S (on P,Q) produces a tuple exactly when a specific (P,Q) pair exists in BOTH — so projecting P from it (I) gives the same set as projecting P from the intersection of {P,Q}-projections (III). So I≡III≡IV. II differs: it joins independently-projected P-values from R and S on P ALONE, matching P values even if their associated Q values differ between R and S — a strictly weaker/different condition, not generally equivalent.
Source: GATE CS 2008 (2008)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.