Relational Algebra & Calculus

Answer & solution
Official answer: 1
1. Evaluate the two projected sets separately before subtracting them. The left selection is an equality join on Y with the additional restriction R.V=V2.
2. Restricting R to V2 leaves (Y3,V2) and (Y2,V2). P has no Y3 tuple and has exactly one Y2 tuple, (X2,Y2,Z2). Thus the left join contributes X2 and its projection is {X2}. P's Y1 and Y4 rows fail the selection.
3. On the right, first keep Q rows with T>2: (X1,Y2,5) and (X1,Y1,6). The rows with T=2 and T=1 are excluded by the strict inequality.
4. The surviving Y2 row matches two R rows, with V3 and V2; the Y1 row matches (Y1,V1). These three join tuples all carry X1. Relational-algebra projection removes duplicates, so the right projected set is {X1}, not three copies of X1.
5. Set difference keeps left-side tuples absent from the right side: {X2}−{X1}={X2}. The result contains exactly 1 tuple.
6. Difference is directional and is not subtraction of the two row counts. Also, relational algebra uses set projection here; SQL without DISTINCT would require separate attention to bag semantics.