The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+15 votes
1.6k views

Database table by name $\text{Loan_Records}$ is given below.

Borrower Bank_Manager Loan_Amount
Ramesh Sunderajan 10000.00
Suresh Ramgopal 5000.00
Mahesh Sunderajan 7000.00

What is the output of the following SQL query?

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

1 Answer

+28 votes
Best answer

Answer is (c).

When we perform natural join on $S$ and $T$ then result will be like this

Borrower Bank Manager Loan Amount
Ramesh Sunderajan $10,000
Ramesh Sunderajan $7000$
Suresh Ramgopala 5000$
Mahesh Sunderajan 10,000$
Mahesh Sunderajan 7000$

After that count (*) will count total tuples present in this table  so here it is 5

answered by Active (4.1k points)
edited by
+5
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"
0
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 ?
0
@learncp: just once as you can see in the output above
0
No sir I have some doubt in it.How this table comes after joining.Plz elaborate it
Answer:

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

39,748 questions
46,764 answers
140,656 comments
58,513 users