GATE / CS ARCHIVE

GATE CSE 2008 / QUESTION 68

Equivalent relational-algebra projections

Database Management Systems · Relational Algebra & Calculus · Full GATE CSE 2008 paper

GATE 2008, Q68 2 marks · MCQ
Report issue

Relational Algebra & Calculus

Question 68, GATE 2008: R(P,Q,R1,R2,R3) and S(P,Q,S1,S2) each have key {P,Q}. Which relational-algebra queries are equivalent? ⋈ denotes natural join. 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))).

(A) I and II only
(B) I and III only
(C) I,II,III only
(D) I,III,IV only
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The natural join matches both common attributes P and Q. Consequently I returns P values of pairs (P,Q) appearing in both relations, exactly III.
2. Since A−(A−B)=A∩B, IV is also equivalent. II only matches P after discarding Q: R containing (p,q1) and S containing (p,q2), q1≠q2, makes II nonempty but I empty.
3. Thus only I, III and IV are equivalent, option D.

Original paper, page 14