Referential Integrity for Tables
Referential Integrity is the state in which all values of all foreign keys are valid. DB2 helps ensure referential integrity between your tables when you define referential constraints.
Referential Integrityis the state in which all values of all foreign keys are valid. DB2 helps ensure referential integrity between your tables when you define referential constraints.
The following illustration shows all the table referential integrity screens and how to invoke them:
This section describes the fields on the Table Create, Table Alter, and Table Template screens that pertain to referential integrity.
- Forgn KeyCreate or update foreign key definitions.
- NSpecifies that no foreign key definition exists.
- YSpecifies that a foreign key has been defined. Enter Y to create a foreign key. The Table Referential Constraints screen appears.
- USpecifies to update an existing foreign key definition. The Table Referential Constraints screen appears.If you are creating, altering, or templating an MQT, and you have specified Initially Deferred in the Data field, the Forgn Key field is unavailable. An MQT cannot be a parent or child in a referential integrity relationship. Initially Deferred is the default value (unless overridden by object definition defaults).
- Column CMDCreate a primary or foreign key definition on a column by entering a referential integrity line command.
- FnDefines a column as part of the foreign key, wherenis the number representing the position of the column within the foreign key for a composite key. The Foreign Key Detail screen appears.
- PnDefines a column as part of the primary key, wherenis the number representing the position of the column within the primary key for a composite key. The PK column is updated to reflect the change. The order of the number is important.
- Table Screen Main CMDEnterUCorUniqueConstto invoke the Unique Constraints Management Screen.
- Table Screen Column HeadingsThe column headings on the Table Screen are as follows:
- PKDisplays the column's key sequence number (if the column is defined as part of the primary key). Enter a new number to update the primary key value.
- UKDisplays Y if the column is defined as part of a unique constraint in the Unique Constraint Management Screen.
- FKDisplays Y if the column is defined as part of a foreign key.