
Download free books at BookBooN.com
An Introduction to Relational Database Theory
 
92 
Relational Algebra – The Foundation
We can take the union of two headings because headings are sets. In particular, a heading is a set of 
attribute name/type pairs. If two headings have different types for some attribute of the same name, then 
their union is a set (of course) but is not a headingbecause a heading cannot have more than one type 
paired with the same name. 
We can take the union of two tuples because tuples are sets. In particular, a tuple is a set of attribute 
name/value pairs. If two tuples have different values for some common attribute, then their union is a  
set (of course) but is not a tuplebecause a tuple cannot have more than one value paired with the  
same name. 
Note that if either operand is empty (its body is the empty set), then so is the result. 
Interesting properties of JOIN
JOIN is both commutative and associative. Commutativity (of a dyadic operator) means that the order of 
operands is insignificant. That is to say, r1 JOIN r2 is equivalent to r2 JOIN r1. Associativity means that 
(r1 JOIN r2) JOIN r3 is equivalent to r1 JOIN (r2 JOIN r3)if we wish to join three or more relations 
together, then we can join them in any order, so to speak. Of course it is no mere coincidence that logical 
AND is also both commutative and associative. 
Properties such as these not only save us a certain amount of thinking when formulating expressions; they 
also help the optimizer to find alternative formulations that might perform better than a straightforward 
implementation of the one written. Tutorial D takes further advantage of these properties by supporting 
an alternative syntax for invoking JOIN, using prefix notation instead of the infix notation I have already 
shown you. In prefix notation the operator name is followed by a list of argument expressions in braces. 
When the operator is associative, we can have any number of arguments: 
JOIN { r1, r2, … }
When there is just one argument, r1, the result is r1. I hope you are wondering what happens if there are 
no arguments at allasking if JOIN { } is defined. Well, it is!but I have to defer the explanation 
until later, for a reason you will understand when I do so. 
As well as being commutative and associative, JOIN is idempotent. Let r be any relation. Then
r JOIN r = r. A dyadic operator is idempotent if, when its operands are the same value, it yields that value. 
Again, it is no mere coincidence that logical AND is idempotent: pp always has the same truth value as p.
There is one further interesting property of 
JOIN, described later, in Section 4.6 of this chapter. 
Two special cases of JOIN
There are two extreme cases concerning common attributes: the case when all attributes are common to 
both operands and the case where none of them are.