1,100 views

Thank you!

Let us make it clear with examples.

Table R :

A B C
4 6 5
7 4 7
8 5 5

Table S:

C D
5 7
6 8

The Simpler explanation goes like:

Step 1: Cartesian product of Table R with Table S. This will look like:

R * S =

A B C C D
4 6 5 5 7
4 6 5 6 8
7 4 7 5 7
7 4 7 6 8
8 5 5 5 7
8 5 5 6 8

Step 2: Now select all the rows having Common Column Value same i.e C column value is same in both C columns.

table becomes:

R ⋈ S :

A B C D
4 6 5 7
8 5 5 7

// as C value is same in both columns no need to write separately.

Now, how to directly Natural Join  R ⋈ S :

Step 1: Check if both table have any Attribute (column name) in common. Here Column = 'C' is common in both R and S.

Step 2: Compare a value of 'C' column from either table (let's say R) with value of 'C' column in other table ( Table S ) and check where is that value in other table.

Step 3: Once a match occurs. Join both Rows keeping common column name occurring only once. // 'C' should be kept once.

Duly noted! :)
What if natural join is done the table itself,

What if natural join is done the table itself,

Let say

$Students1$

 RollNo. CourseNo. CourseName 1 A101 DBMS 2 A102 OS 3 A103 CN

$Students2$

 RollNo. CourseNo. CourseName 1 A101 DBMS 2 A102 OS 3 A103 CN

$Students1\times Students2$

 RollNo. CourseNo. CourseName RollNo. CourseNo. CourseName 1 A101 DBMS 1 A101 DBMS 2 A102 OS 2 A102 OS 3 A103 CN 3 A103 CN

if the natural join is done the table itself, then we can do like this

$Students1 \Join_{<RollNo.=RollNo.,CourseNo.=CourseNo.,CourseName=CourseName>} Students2$

$Students1$

 RollNo. CourseNo. CourseName 1 A101 DBMS 2 A102 OS 3 A103 CN

$(OR)$

$Students2$

 RollNo. CourseNo. CourseName 1 A101 DBMS 2 A102 OS 3 A103 CN

$"$When we apply Natural join in the table itself, then the table itself is the output$."$

please correct me if I'm wrong?