Consider the following two relations, \(\boldsymbol{R(A,B)}\) and \(\boldsymbol{S(A,C)}\):
| \(\boldsymbol{A}\) | \(\boldsymbol{B}\) |
|---|---|
| 10 | 20 |
| 20 | 30 |
| 30 | 40 |
| 30 | 50 |
| 50 | 95 |
| \(\boldsymbol{A}\) | \(\boldsymbol{C}\) |
|---|---|
| 10 | 90 |
| 30 | 45 |
| 40 | 80 |
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