The union operator is not yet implemented – this page serves as the specification for the upcoming implementation. Union is rarely needed in practice.
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.
Bmust have the same primary key attributes. Otherwise, an error will be raised.
Bmay not have any common non-key attributes. Otherwise, an error will be raised.
A + Bwill have the same primary key as
A + Bwill have all the non-key attributes from both
For entities that are found in both
B(based on the primary key), the secondary attributes will be filled from the corresponding entities in
For entities that are only found in either
B, 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¶
A + Bis equivalent to
B + A.
(A + B) + Cis equivalent to
A + (B + C).