Using referential integrity for data consistency

Referential integrity ensures that data is consistent across tables.

About this task

When you define primary and foreign keys, DB2® automatically enforces referential integrity.

As a result, every value of a foreign key in a dependent table must be a value of a primary key in the appropriate parent table. However, DB2 does not enforce informational referential constraints across subsystems.

Recommendation: Use referential integrity to ensure that a column allows only specific values. Set up a master table of allowable values, and define its primary key. Define foreign keys in other tables that must have matching values in their columns. In most cases, you should use the SET NULL delete rule.