Question

Consider the following two relations, R(A,B)R(A,B) and S(A,C)S(A,C):

Relation R(A, B)
R.AR.B
1020
2030
3040
3050
5095
Relation S(A, C)
S.AS.C
1090
3045
4080

The total number of tuples obtained by evaluating the following expression

σB<C(R⋈R.A=S.AS)\sigma_{B < C}(R \bowtie_{R.A = S.A} S)

is _________

Official answer and solution
Official answer
2
From
Official GATE 2024 answer key

Solution

First compute the equijoin R⋈R.A=S.ASR \bowtie_{R.A = S.A} S and then filter the resulting tuples using the condition B<CB < C.

  1. Equijoin R⋈R.A=S.ASR \bowtie_{R.A = S.A} S:
    Matching tuples where R.A=S.AR.A = S.A (which occurs for A=10A = 10 and A=30A = 30) gives 33 tuples:
    • (A=10,  B=20,  C=90)(A = 10,\; B = 20,\; C = 90)
    • (A=30,  B=40,  C=45)(A = 30,\; B = 40,\; C = 45)
    • (A=30,  B=50,  C=45)(A = 30,\; B = 50,\; C = 45)
  2. Selection σB<C\sigma_{B < C}:
    • For (10,20,90)(10, 20, 90): 20<9020 < 90 holds →\rightarrow selected.
    • For (30,40,45)(30, 40, 45): 40<4540 < 45 holds →\rightarrow selected.
    • For (30,50,45)(30, 50, 45): 50<4550 < 45 is false →\rightarrow discarded.

Thus, a total of 2 tuples are obtained.

Final answer

2

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 1 (CS1)
Question
35 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.