Scalable Database Server, HiRDB Version 8 Description

[Contents][Glossary][Index][Back][Next]

5.8 Check constraints

A characteristic of databases is that value ranges, conditions, and other limitations are often imposed on the data contained in the tables. For example, when product information is stored in a database, the product cost cannot be a negative value. This means that there must not be negative product cost values in the database, which suggests that these values should be checked when they are inserted or updated. A check constraint is a function that maintains the integrity of table data by checking a constraint condition when data is inserted or updated and by suppressing operations on data that does not satisfy the condition. In this manual, a table for which a check constraint has been defined is called a check constraint table.

Note that execution of a utility may make it impossible to guarantee the integrity of data in a check constraint table. When this occurs, the check constraint table is placed in check pending status. For details about check pending status, see 5.9 Check pending status.

For details about check constraints, see the HiRDB Version 8 Installation and Design Guide.

Advantages of check constraints
Defining a check constraint reduces the workload required to create a UAP, because the checking of data when it is inserted or updated is automated. The downside is that updating check constraint tables takes longer because of the processing time required to check the integrity of the data.
Organization of this section
(1) Defining a check constraint
(2) Data manipulation and integrity

(1) Defining a check constraint

To define a check constraint, you first specify CHECK with CREATE TABLE of a definition SQL, and then use a search condition to specify the constraint condition for the table value To use the check pending status, specify USE in the pd_check_pending operand or omit specification of the pd_check_pending operand.

(2) Data manipulation and integrity

When you use a data manipulation SQL to update, add, or delete data in a check constraint table, HiRDB performs checking when the SQL is executed in order to guarantee data integrity. However, if you perform certain data operations with the utilities listed below, HiRDB may no longer be able to guarantee data integrity.

If you do perform any of these data operations, you must verify the integrity of the data. For details about how to verify data integrity, see the HiRDB Version 8 Installation and Design Guide. When USE is specified in the pd_check_pending operand, the referencing table is placed in check pending status if you perform any of these data operations.