This repository was archived by the owner on Oct 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Union
Dimitri Yatsenko edited this page Jun 1, 2017
·
5 revisions
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 tuples from both operands.
- As in all operators, the order of the attributes in the operands is not significant.
- Operands
AandBmust have the same primary key attributes. Otherwise, an error will be raised. - Operands
AandBmay not have any common non-key attributes. Otherwise, an error will be raised. - The result
A + Bwill have the same primary key asAandB. - The result
A + Bwill have all the non-key attributes from bothAandB. - For tuples that are found in both
aandb(based on the primary key), the non-key attributes will be filled from the corresponding tuples inAandB. - For tuples that are only found in either
AorB, the other operands' non-key attributes will filled with NULLs.
Example 1 : Note that the order of the attributes does not matter.

Example 2 : Non-key attributes are combined from both relations and filled with NULLs when missing.

- Commutative:
A + Bis equivalent toB + A. - Associative:
(A + B) + Cis equivalent toA + (B + C).