Question:medium

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

Correct Answer: 2

Solution and Explanation

A clean way to read this tuple relational calculus expression is to translate it into an equivalent SQL query, since that makes the logic more familiar. The condition $\exists z \in X(t[P] = z[P])$ is a self-reference that is always satisfied (just pick $z = t$), so it contributes nothing to the filtering and can be dropped. What remains is: keep a tuple $t$ from $X$ only if there is some row in $Y$ with the same $P$ value and $S > 1$. In SQL terms, this is:

SELECT * FROM X WHERE P IN (SELECT P FROM Y WHERE S > 1)

  1. Find which P values in Y have S > 1. Y's rows are (P1, 10), (P1, 15), (P2, 20), (P3, 1). Filtering for S > 1 keeps (P1, 10), (P1, 15), and (P2, 20), while (P3, 1) is dropped since 1 is not greater than 1. So the surviving P values are P1 and P2.
  2. Match these P values against X. X's rows are (P1, Q1, R1), (P2, Q2, R2), (P3, Q3, R2). The row with P1 matches, the row with P2 matches, but the row with P3 does not, since P3 was excluded from the surviving P values in step 1.

So exactly two rows of X, the ones with P1 and P2, satisfy the original expression, while the P3 row is excluded because its only matching row in Y has S = 1, which fails the strict S > 1 test.

$$\boxed{2}$$
Was this answer helpful?
0