GATE CS 2024 Set 1 | Question 35

NAT · 1 mark

Consider the following two relations, \(\boldsymbol{R(A,B)}\) and \(\boldsymbol{S(A,C)}\):

\(\boldsymbol{R}\)
\(\boldsymbol{A}\)\(\boldsymbol{B}\)
1020
2030
3040
3050
5095
\(\boldsymbol{S}\)
\(\boldsymbol{A}\)\(\boldsymbol{C}\)
1090
3045
4080

The total number of tuples obtained by evaluating the following expression

\[\boldsymbol{\sigma_{B \lt C}(R \bowtie_{R.A=S.A} S)}\]

is _________

Answer

2

Explanation

The join pairs each tuple of \(R\) with the tuples of \(S\) that have the same \(A\) value:

  • \(A = 10\): \((10, 20)\) pairs with \((10, 90)\).
  • \(A = 30\): \((30, 40)\) and \((30, 50)\) both pair with \((30, 45)\).
  • \(A = 20\) and \(A = 50\) have no match in \(S\), and the \(S\) tuple with \(A = 40\) has no match in \(R\).

So the join has 3 tuples, whose \((B, C)\) values are \((20, 90)\), \((40, 45)\) and \((50, 45)\). The selection \(B \lt C\) keeps the first two and removes \((50, 45)\), leaving 2 tuples.

Answer: 2