GATE / CS ARCHIVE

GATE CSE 2024 SET 1 / QUESTION 35

Enumerate an equijoin before selection

Database Management Systems · Relational Algebra & Calculus · Full GATE CSE 2024 Set 1 paper

GATE 2024 Set 1, Q35 1 mark · NAT
Report issue

Relational Algebra & Calculus

Question 35, GATE 2024: 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). Join R and S on equal A values, then keep rows with B<C. How many tuples remain?
Tap to enlarge
Answer & solution

Official answer: 2

Approach: First match rows using the join condition, then test the selection condition for each resulting pair.
1. At A=10, R's B=20 matches S's C=90. The equijoin row is (R.A,B,S.A,C)=(10,20,10,90), and 20<90 is true. Below, write the equal A columns once as shorthand (A,B,C).
2. At A=30, there are two R rows and one S row. They produce (30,40,45) and (30,50,45). The first passes 40<45; the second fails 50<45.
3. R's A=20 and A=50 rows find no matching S row. S's A=40 row finds no R partner. An ordinary inner equijoin does not retain these unmatched rows.
4. The join therefore creates three tuples, of which exactly two survive the B<C filter.
Answer: 2. Repeated A values in R must not be collapsed: each matching row contributes its own joined tuple before selection.

Original paper, page 21 · Answer key