The Optimizer can create significantly better query plans if referential relationships are defined between tables specified in the request. The Referential Constraint feature, also called soft referential integrity, allows you tp take advantage of these optimizations without incurring the overhead of enforcing the suggested referential constraints.
- A row having a value for a referencing column can exist in a table even when no equivalent parent table value exists.
- A row can match multiple rows in its parent table when the referenced and referencing column values are compared. This can happen because the candidate key acting as the primary key for the referenced table in the constraint need not be explicitly declared to be unique.
- SQL permits violations without warning.
- FastLoad, MultiLoad, and Teradata Parallel Transporter permits violations against columns defined with Referential Constraints without warning.
Temporal Relationship Constraints can be specified for temporal tables.
Referential Constraints and Temporal Relationship Constraints are a Teradata extension to the ANSI SQL:2011 standard.
Rules for Using Referential Constraints
Other than their not enforcing referential integrity, most of the rules for Referential Constraints are identical to those documented by FOREIGN KEY Constraints and REFERENCES constraints.
- You can specify Referential Constraints for both of the following constraint types.
- FOREIGN KEY (FK_column_set) REFERENCES (parent_table_PK_column_set)
- (NFK_column_set) REFERENCES (parent_table_AK_column_set)
where NFK indicates non-foreign key and parent_table_AK_column_set indicates an alternate key in the parent table.
- Though not enforced by the system, Referential Constraint references count toward the maximum of 64 references permitted for a table referenced as a parent.
- INSERT, DELETE, and UPDATE statements are not permitted against tables with unresolved, inconsistent, or non-valid Referential Constraints. This rule is identical to the rule enforced for standard and batch RI.
- The candidate key acting as the primary key in the referenced table in the constraint need not be explicitly declared to be unique using the PRIMARY KEY or UNIQUE keywords or by declaration as a USI in the table definition.