3,167 views
3 votes
3 votes

What will be the output of Natural join if there is(are) common attribute(s) in two relations but no Common value in these common attribute(s) ?

For example 

Table R

A B
9 7
6 9

Table S

B C
4 1
8 5

Output of R natural join S will be ? 

2 Answers

Best answer
3 votes
3 votes

NATURAL JOIN is a JOIN operation that creates an implicit join clause for you based on the common columns in the two tables being joined. Common columns are columns that have the same name in both tables. A NATURAL JOIN can be an INNER join, a LEFT OUTER join, or a RIGHT OUTER join.

"Natural join consider only those pairs of tuples with same value on those attributes that appear in the schemas of both relations".

Here ,empty relation will be the answer as they have common attributes but not common tuples among them to join over.

selected by
1 votes
1 votes

Hello @rdfan19 , the output here always will be an empty relation since even after getting a common attribute in both relations, the condition of common values for join attribute is not satisfied in Natural Join. 

Thus in terms of join size , the value is 0 tuples as result which is an empty relation. Since no rows can be selected in terms of join attribute( common attribute) B 's value. 

 

But there's a catch, if NO ATTRIBUTES are common in both relations then the result of natural join is Cartesian Product of the relations.

Related questions

0 votes
0 votes
0 answers
1
aditi19 asked May 8, 2019
808 views
how to write the query for natural join on three relations in SQL using the NATURAL JOIN clause?
1 votes
1 votes
0 answers
2
0 votes
0 votes
1 answer
3
Shamim Ahmed asked Jan 8, 2019
755 views
Suppose we have 2 tables R1(ABCD), R2(DE) . R1 has 500 entries whereas R2 has 1500 entries. Here D is a candidate key. If we join them using natural join. How many entire...