Answer: 1
To find the number of tuples returned by the query, we evaluate the two parts of the set difference expression separately.
Part 1: T1=ΠX(σ(P.Y=R.Y∧R.V=′V2′)(P×R))
- We first filter relation R for V=V2: σV=′V2′(R)={(Y3,V2),(Y2,V2)}.
- Next, we join this result with P on Y. The only matching tuple in P with Y∈{Y2,Y3} is (X2,Y2,Z2).
- Projecting on X gives: T1={X2}.
Part 2: T2=ΠX(σ(Q.Y=R.Y∧Q.T>2)(Q×R))
- We first filter relation Q for T>2: σT>2(Q)={(X1,Y2,5),(X1,Y1,6)}.
- We join these tuples with R on Y. Since both Y=Y2 and Y=Y1 exist in R, both tuples join successfully.
- Projecting on X gives: T2={X1}.
Set Difference:
T1−T2={X2}−{X1}={X2}
The final relation contains exactly 1 tuple.