views:

172

answers:

3

This is not a homework problem... I'm studying on my own. If someone could explain to me what is going on here and how to solve this problem it would be greatly appreciated.

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).

+3  A: 

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)}

DrJokepu
A: 

You should answer this question Yourself. Search before asking: http://en.wikipedia.org/wiki/Relational_algebra#Natural_join

Jacek Ławrynowicz
A: 

I assume R(A,B) is the master, S(B,C,D) is the detail and B is the foreign key.

SQL: select * from R, S where R.B = S.B

Then the result is:

A B C D

1 2 4 6

3 4 6 8

3 4 7 9

Rauhotz