Controlling the integrity of your database with constraints
A constraint is a restriction or limitation placed on a database file to ensure that the data in your database remains consistent when you add, change, and remove records.
- Unique constraints and primary key constraints let you create enforced unique keys for a physical file beyond the file access path.
- Check constraints provide another check for the validity of your data by testing the data in an expression.
Primary key and unique constraints can be used as the parent key when adding a referential constraint.
- Setting up constraints for your database
You can use physical file constraints to control data integrity in your database. You can add constraints using the Add Physical File Constraint (ADDPFCST) command or iSeries™ Navigator.
- Removing unique, primary key, or check constraints
You can use the Remove Physical File Constraint (RMVPFCST) command to remove a physical file constraint. The full effects of the command depend on the type of constraint that you remove and how it is used.
- Working with a group of constraints
You can use the Work with Physical File Constraints (WRKPFCST) command to display and manage a list of constraints.
- Unique constraints
Unique constraints act as controls in a database to ensure that rows are unique.
- Primary key constraints
A primary key constraint is a unique key with special attributes that make the key the primary access path for the file.
- Check constraints
You use check constraints to maintain limits on field values so that they conform to your database requirements.
Parent topic:
Managing database files