GATE DA 2025 · SQL Queries

NAT · 2 marks · Problem DBMS-SQL-0041

Consider the following tables, Loan and Borrower, of a bank.\[\begin{array}{c} \textbf{Loan}\\ \begin{array}{|c|c|c|} \hline \textbf{loan\_num} & \textbf{branch \_ name} & \textbf{amount} \\ \hline L11 & \text{Banjara Hills} & 90000 \\ \hline L14 & \text{Kondapur} & 50000 \\ \hline L15 & \text{SR Nagar} & 40000 \\ \hline L22 & \text{SR Nagar} & 25000 \\ \hline L23 & \text{Balanagar} & 80000 \\ \hline L25 & \text{Kondapur} & 70000 \\ \hline L19 & \text{SR Nagar} & 65000 \\ \hline \end{array}\end{array}\]\[\begin{array}{c} \textbf{Borrower} \\ \begin{array}{|c|c|} \hline \textbf{customer\_name} & \textbf{loan\_num} \\ \hline \text{Anand} & \text{L11} \\ \hline \text{Karteek} & \text{L11} \\ \hline \text{Karteek} & \text{L14} \\ \hline \text{Ankita} & \text{L15} \\ \hline \text{Gopal} & \text{L19} \\ \hline \text{Karteek} & \text{L22} \\ \hline \text{Karteek} & \text{L23} \\ \hline \text{Sunil} & \text{L23} \\ \hline \text{Sunil} & \text{L25} \\ \hline \end{array}\end{array}\]Query: \(\pi_{\text{branch\_name, customer\_name}}(\text{Loan} \Join \text{Borrower}) \div \pi_{\text{branch\_name}}(\text{Loan})\)where \(\Join\) denotes natural join. The number of tuples returned by the above relational algebra query is (Answer in integer)

Numerical answer (NAT).

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solutionFirst compute \(\text{Loan}\Join\text{Borrower}\) (natural join on \(\text{loan\_num}\)), then project \((\text{branch\_name},\text{customer\_name})\). Tracing each loan to its branch and borrower(s):Karteek appears against loans in all four branches (Banjara Hills via L11, Kondapur via L14, SR Nagar via L22, Balanagar via L23). Every other customer (Anand, Ankita, Gopal, Sunil) is associated with only \(1\)-\(2\) branches, not all four.Since \(\pi_{\text{branch\_name}}(\text{Loan})=\{\text{Banjara Hills, Kondapur, SR Nagar, Balanagar}\}\) (\(4\) distinct branches), the division operation returns exactly the customer names associated with every one of these \(4\) branches — only Karteek qualifies.Answer: 1Click Here for Detail SolutionGateOverflow discussion: https://gateoverflow.in/460970/gate-da-2025-question-52

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com