How to compute a natural join?

kylex picture kylex · Feb 13, 2009 · Viewed 7.2k times · Source

Could someone explain to me what is going on here and how to solve this problem?

Suppose relation R(A,B) has the tuples:

A B
1 2
3 4
5 6

and the relation S(B,C,D) has tuples:

B C D
2 4 6
4 6 8
4 7 9

Compute the natural join of R and S. Then, identify which of the following tuples is in the natural join
R |><| S. You may assume each tuple has schema (A,B,C,D).

I don't know what a natural join truly means. Can you explain it to me?

Answer

Tamas Czinege picture Tamas Czinege · Feb 13, 2009

A natural join is joining ("sticking together") elements from two relations where there is a match. In this example

  • (1, 2) matches (2, 4, 6) so you get (1, 2, 4, 6)
  • (3, 4) matches (4, 6, 8) so you get (3, 4, 6, 8)
  • (3, 4) matches (4, 7, 9) so you get (3, 4, 7, 9)

So the natural join is {(1, 2, 4, 6), (3, 4, 6, 8), (3, 4, 7, 9)}