Ways to maintain data integrity

When you add or modify data in a Db2 table, you need to ensure that the data is valid. Two techniques that you can use to ensure valid data are constraints and triggers.

Constraints are rules that limit the values that you can insert, delete, or update in a table. There are two types of constraints:

  • Check constraints determine the values that a column can contain. Check constraints are discussed in Check constraints.
  • Referential constraints preserve relationships between tables. Referential constraints are discussed in Referential constraints. A specific type of referential constraints, the informational referential constraint, is discussed in Informational referential constraints.

To maintain data integrity Db2 enforces check constraints and referential constraints on data in a table. When these types of constraints are violated or might be violated, Db2 places the table space or partition that contains the table in CHECK-pending status.

Triggers are a series of actions that are invoked when a table is updated. Triggers are discussed in Creating a trigger.