Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Natural join if no common attributes

Tags:

What will natural join return in relational algebra if tables don't have attributes with same names? Will it be null or the same as cross-product (Cartesian operator)?

like image 767
Hate Avatar asked Jan 27 '13 14:01

Hate


People also ask

Can we join two tables if they do not have common column name?

Yes, you can! The longer answer is yes, there are a few ways to combine two tables without a common column, including CROSS JOIN (Cartesian product) and UNION. The latter is technically not a join but can be handy for merging tables in SQL. In this article, I'll guide you through the different solutions with examples.

What is the major drawback of natural join?

The common complaint about NATURAL JOIN is that since shared columns aren't explicit, after a schema change inappropriate column pairing may occur. And that may be the case in a particular development environment.

How do I join two tables when there is no common column in SQL?

Method 1 (Cross Join): As you might have heard of several joins like inner join, outer join, in the same way cross join is there, which is used to form the Cartesian product of the tables without or with common columns.


2 Answers

If there are no attributes in common between two relations and you perform a natural join, it will return the cartesian product of the two relations.

like image 80
Andrew Martin Avatar answered Sep 20 '22 12:09

Andrew Martin


A cartesian product of two tables will be returned.This is because when we perform any JOIN operation on two tables a cartesian product of those tables is performed and then based on any select condition in WHERE clause the resultant rows are returned.But here as there are no common columns the process stops after cartesian product.

like image 24
Prashant_M Avatar answered Sep 19 '22 12:09

Prashant_M