Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top