Relational Algebra - Natural join - few basics

4.8k views Asked by At

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.

2

There are 2 answers

4
Aziz Shaikh On BEST ANSWER
  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?

0
nvogel On
  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.