Consider the following tables, Loan and Borrower, of a bank.
| 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 |
| customer_name | loan_num |
|---|---|
| Anand | L11 |
| Karteek | L11 |
| Karteek | L14 |
| Ankita | L15 |
| Gopal | L19 |
| Karteek | L22 |
| Karteek | L23 |
| Sunil | L23 |
| Sunil | L25 |
Query: \(\pi_{\textbf{branch\_name},\ \textbf{customer\_name}}(\textbf{Loan} \bowtie \textbf{Borrower}) \div \pi_{\textbf{branch\_name}}(\textbf{Loan})\)
where \(\bowtie\) denotes natural join.
The number of tuples returned by the above relational algebra query is ________
(Answer in integer)
Answer
1
Explanation
Division keeps the customers who are paired with every branch in \(\pi_{\textbf{branch\_name}}(\textbf{Loan})\), that is, with all four of Banjara Hills, Kondapur, SR Nagar and Balanagar.
The natural join matches on loan_num, which gives each customer's branches:
- Anand: Banjara Hills (L11)
- Karteek: Banjara Hills (L11), Kondapur (L14), SR Nagar (L22), Balanagar (L23)
- Ankita: SR Nagar (L15); Gopal: SR Nagar (L19)
- Sunil: Balanagar (L23), Kondapur (L25)
Only Karteek appears with all four branches, so the query returns the single tuple (Karteek).
Answer: 1