Verifying referential constraints

 

The system automatically verifies the validity of a referential constraint when you add the constraint with the Add Physical File Constraint (ADDPFCST) command. The system verifies that every non-null value in the foreign key matches a corresponding value in the parent key.

If the verification is successful, the constraint rules are enforced on subsequent accesses by a user or an application program. An unsuccessful verification causes the constraint to be marked as check pending. If the constraint is added with the ADDPFCST command, it will be in check pending but disabled state.

It is not uncommon to add a referential constraint to existing files that contain large amounts of data. The ADDPFCST command can take several hours to complete when a very large number of records are involved. The add process places an exclusive lock on the files. You should take this time factor and file availability into consideration before you add a referential constraint.

 

Parent topic:

Ensuring data integrity with referential constraints