This is no longer maintained and has been superseded by datajoint-company/datajoint-docs. Please file new issues there (or help contribute!). We are currently migrating and generating new content until December 2022 after which we’ll be decomissioning https://docs.datajoint.org and https://tutorials.datajoint.org in favor of https://datajoint.com/docs/.
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).