IAE Academy

GATE 2025 DA Q.62: solution and answer

GATE 2025 · DAQ.62 · 2 marks · NAT

Consider the following tables, Loan and Borrower, of a bank.

Query: where denotes natural join.

The number of tuples returned by the above relational algebra query is ______ (Answer in integer)

GATE 2025 DA question 62: Two tables.Tap to open full size
Figure from the GATE 2025 DA paper. It is part of the question.
Figure description

Two tables. Loan(loan_num, branch_name, amount): (L11, Banjara Hills, 90000), (L14, Kondapur, 50000), (L15, SR Nagar, 40000), (L22, SR Nagar, 25000), (L23, Balanagar, 80000), (L25, Kondapur, 70000), (L19, SR Nagar, 65000). Borrower(customer_name, loan_num): (Anand, L11), (Karteek, L11), (Karteek, L14), (Ankita, L15), (Gopal, L19), (Karteek, L22), (Karteek, L23), (Sunil, L23), (Sunil, L25).

Answer and solution

ANSWER

The query returns 1 tuple, namely Karteek.

Official answer: 1Source: Official answer key, GATE 2025 DA (IIT Roorkee)

  1. Division returns every value of the attribute that is in but not in (here customer_name) that is paired in with every tuple of . The query is .

  2. The divisor is . Duplicates collapse, so has 4 branches.

  3. Natural join on loan_num, row by row: L11 gives (Banjara Hills, Anand) and (Banjara Hills, Karteek); L14 gives (Kondapur, Karteek); L15 gives (SR Nagar, Ankita); L19 gives (SR Nagar, Gopal); L22 gives (SR Nagar, Karteek); L23 gives (Balanagar, Karteek) and (Balanagar, Sunil); L25 gives (Kondapur, Sunil). After projection onto (branch, customer) there are 9 distinct tuples.

  4. Group the branches by customer: Anand ; Ankita ; Gopal ; Sunil ; Karteek .

  5. A customer is in the result only if their set of branches contains all 4 branches of . Karteek does. Sunil lacks Banjara Hills and SR Nagar, and the others each have one branch.

  6. The result is , so the query returns 1 tuple.

KEY IDEA

Division keeps the customers whose set of branches (after the join) contains every branch of the divisor. Build the joined (branch, customer) pairs, group them by customer, and compare each group with the full branch set.

WATCH OUT FOR

Taking the divisor to be the branches of one particular customer, or counting the branch list with duplicates instead of as a set. Another slip is missing that Karteek reaches SR Nagar through L22 and Balanagar through L23, so he really does cover all four branches.

From the GATE 2025 DA paper. Every question of this paper · Download the full paper · All 5 Relational algebra questions, with notes

More Relational algebra questions