Question:

Let there be two relations \(X\) and \(Y\) as shown. \(X\) has three columns \(P\), \(Q\) and \(R\). \(Y\) has two columns \(P\) and \(S\).

Relation X:

PQR
P1Q1R1
P2Q2R2
P3Q3R2

Relation Y:

PS
P110
P115
P220
P31

Consider that the following tuple relational calculus expression is evaluated.
\[ \{t \mid t \in X \wedge \exists z \in X (t[P] = z[P]) \wedge \exists m \in Y (m[P] = t[P] \wedge m[S] > 1)\} \]
The number of tuples that will be returned is _______. (Answer in integer)

Show Hint

The self-reference on X is always true; the real filter checks whether each tuple's P value appears in Y with an S value strictly greater than 1.
Updated On: Jul 22, 2026
Show Solution
collegedunia
Verified By Collegedunia

Correct Answer: 2

Solution and Explanation

Step 1: Understand each part of the expression.
The expression picks out tuples \(t\) from relation \(X\) that satisfy two conditions.
The middle condition \(\exists z \in X(t[P] = z[P])\) asks: does some tuple \(z\) in \(X\) exist with the same \(P\) value as \(t\)? Since \(t\) itself is already a tuple of \(X\), we can always choose \(z = t\), and then \(t[P] = z[P]\) is trivially true. So this condition holds for every tuple in \(X\) and does not filter out anything.
The real filter is the last condition: \(\exists m \in Y(m[P] = t[P] \wedge m[S] > 1)\). This asks whether some row \(m\) in \(Y\) has the same \(P\) value as \(t\) and has \(S > 1\).

Step 2: Check the condition for each tuple of X.
X has three tuples: \((P1, Q1, R1)\), \((P2, Q2, R2)\), \((P3, Q3, R2)\). Check the \(Y\) rows for each \(P\) value.
For \(P1\): Y has rows \((P1, 10)\) and \((P1, 15)\). Both have \(S > 1\). So a matching \(m\) exists, and the condition is true.
For \(P2\): Y has the row \((P2, 20)\). Since \(20 > 1\), the condition is true.
For \(P3\): Y has only the row \((P3, 1)\). Here \(S = 1\), and \(1 > 1\) is false. There is no other row in \(Y\) with \(P = P3\), so no matching \(m\) exists. The condition is false for \(P3\).

Step 3: Collect the tuples that pass.
The tuple with \(P1\), namely \((P1, Q1, R1)\), passes.
The tuple with \(P2\), namely \((P2, Q2, R2)\), passes.
The tuple with \(P3\), namely \((P3, Q3, R2)\), fails and is excluded.

Final Answer:
Exactly 2 tuples of \(X\) satisfy the expression. \[ \boxed{2} \]
Was this answer helpful?
0
0

Top GATE DA Data Science and Artificial Intelligence Questions

View More Questions

Top GATE DA Database Management Systems Questions

View More Questions