GATE 2026 DA – Question 42
Consider the given relations $X$, $Y$ and $Z$. The relation $X$ has three columns $P$, $Q$ and $R$. The relation $Y$ has three columns $P$, $Q$ and $S$. The relation $Z$ has two columns $P$ and $T$.
| X: P | Q | R |
|---|---|---|
| P1 | Q1 | R1 |
| P2 | Q2 | R2 |
| P3 | Q3 | R2 |
| Y: P | Q | S |
|---|---|---|
| P1 | Q1 | 2 |
| P1 | Q2 | 5 |
| P2 | Q1 | 6 |
| P3 | Q3 | 1 |
| Z: P | T |
|---|---|
| P1 | T1 |
| P3 | T2 |
| P4 | T3 |
| P4 | NULL |
Consider the relational algebra expression
$$\Pi_{P,R,S}\left[\left(\sigma_{(Q = Q3 \vee R = R2)}[X \bowtie Y]\right) \bowtie \left(\sigma_{(S > 1)}[Y \bowtie Z]\right)\right]$$
where $\bowtie$ denotes natural join operation.
Which of the following options is the correct output for the given expression?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (D) Zero rows
Explanation
$X \bowtie Y$ joins on $P$ and $Q$ and gives (P1, Q1, R1, 2) and (P3, Q3, R2, 1). The selection $Q = Q3 \vee R = R2$ keeps only (P3, Q3, R2, 1). $Y \bowtie Z$ joins on $P$ and gives (P1, Q1, 2, T1), (P1, Q2, 5, T1) and (P3, Q3, 1, T2), and $S > 1$ keeps the first two. The final join is on the common columns $P$, $Q$ and $S$. The left side has $P = P3$ and the right side has only $P = P1$, so nothing matches and the output has zero rows.