# GATE | GATE CS 2019 | Question 63

Consider the following relation P(X, Y, Z), Q(X, Y, T) and R(Y, V):

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

`πx(σ(P.Y = R.Y ∧ R.V = V(P X R))) - πx(σ(Q.Y = R.Y ∧ Q.T > 2(Q X R))) `

Note: This was Numerical Type question.
(A) 3
(B) 1
(C) 2
(D) 4

Explanation: Query-1:

`πx(σ(P.Y = R.Y ∧ R.V = V(P X R))) `

It will satisfy only one row:

```X  Y  Z  Y  V
-------------------
X2  Y2  Z2  Y2  V2
------------------- ```

Only column X will be selected.

```X
-----
X2
----- ```

Query-2:

`πx(σ(Q.Y = R.Y ∧ Q.T > 2(Q X R))) `

It will satisfy only two row:

```X  Y  T  Y  V
-------------------
X1  Y2  5  Y2  V3
X1  Y1  6  Y1  V1
------------------- ```

Only column X will be selected.

```X
-----
X1
----- ```

Note that relational algebra return unique tuples only.

Now,

```= πx(σ(P.Y = R.Y ∧ R.V = V(P X R)))
= (Query-1) - (Query-2)
= X2 - X1
= X2 ```

Note that {(Query-1) – (Query-2)} will return all tuples from query-1 those are not in query-2.

Quiz of this Question

My Personal Notes arrow_drop_up

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.