Union¶
The union operator is not yet implemented – this page serves as the specification for the upcoming implementation. Union is rarely needed in practice.
Union operator +
¶
The result of the union operator A + B
contains all the entities from both operands.
Entity normalization requires that the operands in a union both belong to the same entity type with the same primary key using homologous attributes.
In the absence of any secondary attributes, the result of a union is the simple set union.
When secondary attributes are present, they must have the same names and datatypes in both operands. The two operands must also be disjoint, without any duplicate primary key values across both inputs. These requirements prevent ambiguity of attribute values and preserve entity identity.
Principles of union¶
As in all operators, the order of the attributes in the operands is not significant.
Operands
A
andB
must have the same primary key attributes. Otherwise, an error will be raised.Operands
A
andB
may not have any common non-key attributes. Otherwise, an error will be raised.The result
A + B
will have the same primary key asA
andB
.The result
A + B
will have all the non-key attributes from bothA
andB
.For entities that are found in both
A
andB
(based on the primary key), the secondary attributes will be filled from the corresponding entities inA
andB
.For entities that are only found in either
A
orB
, the other operand’s secondary attributes will filled with null values.
Examples of union¶
Example 1 : Note that the order of the attributes does not matter.
Example 2 : Non-key attributes are combined from both tables and filled with NULLs when missing.
Properties of union¶
Commutative:
A + B
is equivalent toB + A
.Associative:
(A + B) + C
is equivalent toA + (B + C)
.