2

I have two basics questions regarding the natrual join.

Suppose A is a relation, then:

  1. Is (A) natrual join (A) = A ?

  2. Is (A) natrual join (empty set) = A ?

As far as I understand the answer to both questions is YES, am I right?

NOTE : this is not an homework question, I'm just trying to understand few basics of natrual join.

Thank you.

SyndicatorBBB
  • 1,757
  • 2
  • 26
  • 44

2 Answers2

4
  1. Is (A) natrual join (A) = A? Yes
  2. Is (A) natrual join (empty set) = A? No

Here is a working demo.

Since natural join compares all columns in the two tables that have the same column names and return only one column for same-name columns, A join A will result in A. For point #2, join will not match any rows so the result will be empty table (not A).

Note: The Cartesian product of A and the empty set is the empty set

Also, check this Why is the Cartesian product of a set A and empty set an empty set?

Community
  • 1
  • 1
Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
  • My mistake. I didn't note that I'm talking on Relational Algebra. According to the definition of natural join in relational algebra it seems like (2) is also correct... Am I right? – SyndicatorBBB Sep 11 '13 at 10:53
  • But according to the defintion of natural join - (R) natural join (S) is equal to (R) X (S) if (R) intersect (S) is the empty set. That is, if R and S don't have any matching columns we get the Cartesian Product. I imply from this that (R) natrual join (empty set) will be R. – SyndicatorBBB Sep 11 '13 at 10:59
  • Well for some reason I can't find it simple as it is. I use the book "Database system concept" as a guide where the cartesian product is defined as following : for each tuple in r attach all the tuples in s. Anyway thank you for your help. I appricate it very much. – SyndicatorBBB Sep 11 '13 at 11:32
  • "for each tuple in r attach all the tuples in s" which is correct except when s is empty. Good luck! – Aziz Shaikh Sep 11 '13 at 12:39
2
  1. Correct

  2. The question is ambiguous and the answer could be yes or no. Natural join is an operation on two relations. "Empty set" in this context might mean at least two things: (a) a relation with no tuples (zero cardinality); (b) a relation with an empty heading (zero degree), meaning it doesn't have any attributes but may or may not contain a tuple.

2(a) if either A or B has zero cardinality then A ⋈ B is also empty. If A and B have different (and non-empty) headings then A ⋈ B is literally incomparable to A because the result of the join has a different heading to A, so in that case it wouldn't be correct to say that the result is "equal to" A. A ⋈ B could result in the same heading as A of course in which case A ⋈ B might equal A.

2(b) there are only two relations with an empty heading, one with zero tuples and one with a single tuple. By convention they are called DUM and DEE respectively. A ⋈ DUM results in a relation with the same heading as A but with zero tuples. A ⋈ DEE = A.

nvogel
  • 24,981
  • 1
  • 44
  • 82