Skip to content
GATEiit

GATE CSE 2019 Q65: Tuples returned by difference of two relational algebra projections

Syllabus topic: Relational model: relational algebra, tuple calculus and SQL

Question

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

P
XYZ
X1Y1Z1
X1Y1Z2
X2Y2Z2
X2Y4Z4
Q
XYT
X2Y12
X1Y25
X1Y16
X3Y31
R
YV
Y1V1
Y3V2
Y2V3
Y2V2

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

∏X(σ(P.Y=R.Y ∧ R.V=V2)(P×R))−∏X(σ(Q.Y=R.Y ∧ Q.T>2)(Q×R))

Answer: ________.

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 1 (official GATE 2019 final answer key)

Concept used: A selection with an equality on the common attribute over a Cartesian product acts as a join; projection removes duplicates, and set difference keeps the values in the first result that are not in the second.

Concept notes

Loading notes…

First step: Find the Y values in R with V = V2 and the X values of P rows having those Y; separately find the X values of Q rows with T > 2 whose Y appears in R; then subtract the second set from the first.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Relational model: relational algebra, tuple calculus and SQL

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key