The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+17 votes

Database table by name $\text{Loan_Records}$ is given below.
$$\begin{array}{|c|c|c|} \hline \textbf {Borrower} & \textbf {Bank_Manager} &\textbf {Loan_Amount} \\\hline  \text{Ramesh }& \text{Sunderajan} & 10000.00 \\\hline \text{Suresh} & \text{Ramgopal} & 5000.00 \\\hline \text{Mahesh} & \text{Sunderajan} & 7000.00\\\hline \end{array}$$
What is the output of the following SQL query?

SELECT count(*)
    SELECT Borrower, Bank_Manager FROM Loan_Records) AS S 
    (SELECT Bank_Manager, Loan_Amount FROM Loan_Records) AS T
  1. $3$
  2. $9$
  3. $5$
  4. $6$
asked in Databases by Veteran (96.1k points)
edited by | 2.2k views

How the tables are joined in this , please somebody explain ?
@Arjun sir

1 Answer

+30 votes
Best answer
The answer is (C).

When we perform the natural join on $S$ and $T$ then result will be like this
\textbf{Borrower}&   \textbf{Bank_Manager}&  \textbf{Loan_Amount} \\\hline
\text{Ramesh}&     \text{Sunderajan}&    10000.00  \\ \hline  
\text{Ramesh}&     \text{Sunderajan}&7000.00 \\     \hline
\text{Suresh}&     \text{Ramgopala}&  5000.00    \\\hline
\text{Mahesh}&     \text{Sunderajan}& 10000.00     \\\hline
\text{Mahesh}&     \text{Sunderajan}&   7000.00 \\\hline   
After that count (*) will count total tuples present in this table  so here it is $5.$
answered by Active (4.1k points)
edited by
No need of any doubt.
"The result of the natural join on R,S is the set of all combinations of tuples in R and S that are equal on their common attribute names"
Does the resulting table after natural join include the common attribute twice, or as a single column only ? I mean to say if S contains a,b and T contains a,c , then S NATURAL JOIN T will contain a,b,c or a,b,a,c ?
@learncp: just once as you can see in the output above
No sir I have some doubt in it.How this table comes after joining.Plz elaborate it

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,535 questions
54,117 answers
71,027 users