Skip to content
Related Articles

Related Articles

GATE | GATE CS 2019 | Question 63
  • Last Updated : 23 Dec, 2020

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


Answer: (B)

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 three row: 
 

X  Y  T  Y  V
-------------------
X1  Y2  5  Y2  V3
X1  Y2  5  Y2  V2
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

So, answer is 1

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

Quiz of this Question
 


Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :