DB2 10.5 for Linux, UNIX, and Windows

Informational constraints

An informational constraint is a constraint attribute that can be used by the SQL compiler to improve the access to data. Informational constraints are not enforced by the database manager, and are not used for additional verification of data; rather, they are used to improve query performance.

You define informational constraints by using the CREATE TABLE or ALTER TABLE statement. You first add constraints and then associate them with constraint attributes, specifying whether the database manager is to enforce the constraints. For primary key constraints, unique constraints, and check constraints, you can further specify that the constraint can be trusted. For referential integrity constraints, if the constraint is not enforced, you can further specify whether the constraint can be trusted. A not-enforced and not-trusted constraint is also known as a statistical referential integrity constraint. You can specify whether a referential integrity constraint or check constraint is to be used for query optimization.

Informational RI (referential integrity) constraints are used to optimize query performance, the incremental processing of REFRESH IMMEDIATE MQT, and staging tables. Query results, MQT data, and staging tables might be incorrect if informational constraints are violated.

For example, the order in which parent-child tables are maintained is important. When you want to add rows to a parent-child table, you must insert rows into the parent table first. To remove rows from a parent-child table, you must delete rows from the child table first. This ensures that there are no orphan rows in the child table at any time. Otherwise the informational constraint violation might affect the correctness of queries being executed during table maintenance, as well as the correctness of the incremental maintenance of dependent MQT data and staging tables.

You can create a not-enforced primary key or unique constraint for either a column-organized or row-organized table. Unlike an enforced primary key or unique constraint, a not-enforced primary key or unique constraint does not create an index on the data. Specify an informational constraint only if the table data is independently known to conform to the constraint. Because the DB2® database manager does not enforce uniqueness for these constraints, if the table data violates the not-enforced constraint, incorrect results can occur. You cannot reference not-enforced primary key constraints in any enforced referential integrity definitions.