# GATE Papers >> CSE >> 2019 >> Question No 65

Question No. 65

Consider the following relations P(X,Y,Z), Q(X,Y,T) and R(Y,V).

 P X Y Z X1 Y1 Z1 X1 Y1 Z2 X2 Y2 Z2 X2 Y4 Z4

 Q X Y T X2 Y1 2 X1 Y2 5 X1 Y1 6 X3 Y3 1

 R Y V Y1 V1 Y3 V2 Y2 V3 Y2 V2

How many tuples will be returned by the following relational algebra query?

$\prod\nolimits_X(\sigma_{\left(P.Y=R.Y\wedge R.V=V2\right)}(P\times R))-\prod\nolimits_X(\sigma_{\left(Q.Y=R.Y\wedge Q.T>2\right)}(Q\times R))$

##### Answer : 1 to 1

Solution of Question No 65 of GATE 2019 CSE Paper

${\mathrm\pi}_{\mathrm x}\left({\mathrm\sigma}_{\left(\mathrm P.\mathrm Y=\mathrm R.\mathrm Y\wedge\mathrm R.\mathrm V=\mathrm V2\right)}\right)^{\left(\mathrm P\times\mathrm R\right)})$

It joins P and R with condition of $\left(\mathrm P.\mathrm Y=\mathrm R.\mathrm Y\wedge\mathrm R.\mathrm V=\mathrm V2\right)$ and it returns only one column that is X. The output will be one x'2

${\mathrm\pi}_{\mathrm x}\left({\mathrm\sigma}_{\left(\mathrm Q.\mathrm Y=\mathrm R.\mathrm Y\wedge\mathrm Q.\mathrm T>2\right)}\right)^{\left(\mathrm Q\times\mathrm R\right)})$

It joins P and R with condition of $\left(\mathrm Q.\mathrm Y=\mathrm R.\mathrm Y\wedge\mathrm Q.\mathrm T=\mathrm T>2\right)$ and it returns only one column that is X. The output will be two x'1 's but relational algebra eliminates duplication so here only x1.

${\mathrm\pi}_{\mathrm x}\left({\mathrm\sigma}_{\left(\mathrm P.\mathrm Y=\mathrm R.\mathrm Y\wedge\mathrm R.\mathrm V=\mathrm V2\right)}\right)^{\left(\mathrm P\times\mathrm R\right)})-{\mathrm\pi}_{\mathrm x}\left({\mathrm\sigma}_{\left(\mathrm Q.\mathrm Y=\mathrm R.\mathrm Y\wedge\mathrm Q.\mathrm T>2\right)}\right)^{\left(\mathrm Q\times\mathrm R\right)})$ output will be only x2 so1 tuple has returned.