The GATE Grind

GATE 2026 CS (CS1) – Question 43

Databases · Relational Model: Relational Algebra, Tuple Calculus, SQL · 2 marks · Multiple choice

Consider a relational database schema with two relations $R(P, Q)$ and $S(X, Y)$. Let $E = \{\langle u \rangle \mid \exists v \exists w \, \langle u, v \rangle \in R \land \langle v, w \rangle \in S\}$ be a tuple relational calculus expression. Which one of the following relational algebraic expressions is equivalent to $E$?

  1. $\Pi_P(R \bowtie_{R.P = S.X} S)$
  2. $\Pi_P(S \bowtie_{S.X = R.Q} R)$
  3. $\Pi_P(R \bowtie_{R.P = S.Y} S)$
  4. $\Pi_P(S \bowtie_{S.Y = R.Q} R)$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) $\Pi_P(S \bowtie_{S.X = R.Q} R)$

Explanation

Examine the tuple relational calculus expression:
$$E = \{\langle u \rangle \mid \exists v \exists w \, \langle u, v \rangle \in R \land \langle v, w \rangle \in S\}$$
- $\langle u, v \rangle \in R(P, Q) \implies u$ corresponds to attribute $P$ of $R$, and $v$ corresponds to attribute $Q$ of $R$.
- $\langle v, w \rangle \in S(X, Y) \implies v$ corresponds to attribute $X$ of $S$, and $w$ corresponds to attribute $Y$ of $S$.
- The shared variable $v$ imposes the join condition: $R.Q = S.X$.
- The output tuple $\langle u \rangle$ projects the attribute corresponding to $u$, which is $P$ of relation $R$.

In relational algebra, this is expressed as:
$$\Pi_P(R \bowtie_{R.Q = S.X} S) \equiv \Pi_P(S \bowtie_{S.X = R.Q} R)$$

Therefore, option (B) is correct.