Jeff Pang Jeff Pang - 1 year ago 116
SQL Question

Database- Relational Algebra natural joins 2 tables consist 2 same column names

natural joins 2 relations

I have read through an example of

Natural Join
involving 2 relations that have 2 identical columns name. I understand those with 1 identical columns name in 2 tables, but really no idea about for this case.
Could anyone explain to me how to get that output (not in Sql command)?


Answer Source

The common column are B and D, so rows from both sides are matched if they have the same B and D values.
The common (B,D) values in this example are (1,a) and (2,b).
2 rows from r' with (1,a) are matched to 2 rows from s', creating 4 combinations.
1 row from r' with (2,b) is matched to 1 row from s', creating a single combination.
Therefore, 5 rows in the result set.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download