IAE Academy

GATE 2024 CS1 Q.35: solution and answer

GATE 2024 · CS1Q.35 · 1 mark · NAT

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

The total number of tuples obtained by evaluating the following expression

is _________

GATE 2024 CS1 question 35: Two tables.Tap to open full size
Figure from the GATE 2024 CS1 paper. It is part of the question.
Figure description

Two tables. R(A,B) has rows (10,20), (20,30), (30,40), (30,50), (50,95). S(A,C) has rows (10,90), (30,45), (40,80). Then the expression sigma_B<C(R join_R.A=S.A S).

Answer and solution

ANSWER

The expression returns 2 tuples: and .

Official answer: 2Source: Official answer key, GATE 2024 CS1 (IISc Bengaluru)

  1. The join condition pairs a tuple of with a tuple of only when their values are equal.

  2. : has and has . This gives the joined tuple .

  3. : has , but has no tuple with . Nothing joins.

  4. : has and , and has . This gives and .

  5. : has , but has no tuple with . Nothing joins. The tuple of has no partner in either.

  6. The join therefore has 3 tuples: , and .

  7. Apply to each tuple: is true, so it is kept. is true, so it is kept. is false, so it is dropped.

  8. Two tuples remain, so the answer is 2.

KEY IDEA

Evaluate the equi-join first by matching equal values. Then filter the joined tuples with the selection condition .

WATCH OUT FOR

Counting the join result (3 tuples) and forgetting the selection . Another slip is comparing with before joining, or treating the non-matching tuples (, , ) as part of the join.

From the GATE 2024 CS1 paper. Every question of this paper · Download the full paper · All 13 Relational algebra questions, with notes

More Relational algebra questions