Let us make it clear with examples.
Table R :
Table S:
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 :
// 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.