Natural Join

What does the Natural Join operator do?

	combine two relations into a single relation

Compute the Natural Join of the relations.

	A B
	1 2
	2 1
	2 3

	B C
	1 1
	1 2
	2 2


















What's the result of SNAP |X| CSG?

StudID  Name         Address       Phone
12345   C. Brown     12 Apple St.  555-1234
67890   L. Van Pelt  34 Pear Ave.  555-5678
22222   P. Patty     56 Grape St.  555-9999

Course	StudID  Grade
CS101	12345   A
CS101	67890   B
EE200	12345   C
EE200	22222   B+
CS101	33333   A-
PH100	67890   C+

StudID  Name	     Address	   Phone     Course  Grade
12345   C. Brown     12 Apple St.  555-1234  CS101   A
12345   C. Brown     12 Apple St.  555-1234  EE200   C
67890   L. Van Pelt  34 Pear Ave.  555-5678  CS101   B
67890   L. Van Pelt  34 Pear Ave.  555-5678  PH100   C+
22222   P. Patty     56 Grape St.  555-9999  EE200   B+


















Classwork

You may work with a partner.

Compute the Natural Join of the relations.

	B C D
	1 2 1
	2 1 2
	2 2 3

	A E C
	1 2 2
	2 1 1
	2 1 2


















Natural Join with 2 common attributes

Compute the Natural Join of the relations.

	A B C
	1 2 3
	2 2 4
	2 3 5

	A B D
	1 1 1
	2 2 1
	2 2 2


















Natural Join with no common attributes

Compute the Natural Join of the relations.

	A B
	1 2
	2 1

	C D
	1 1
	1 2
	2 2

	A B C D
	1 2 1 1
	1 2 1 2
	1 2 2 2
	2 1 1 1
	2 1 1 2
	2 1 2 2