This chapter explains how integrity constraints enforce the business rules associated with a database and prevent the entry of invalid information into tables.
This chapter contains the following sections:
Business rules specify conditions and relationships that must always be true or must always be false. For example, each company defines its own policies about salaries, employee numbers, inventory tracking, and so on. It is important that data maintain data integrity, which is adherence to these rules, as determined by the database administrator or application developer.
When designing a database application, developers have various options for guaranteeing the integrity of data stored in the database. These options include:
This chapter explains the basic concepts of integrity constraints.
An integrity constraint is a schema object that is created and dropped using SQL. To enforce data integrity, use integrity constraints unless it is not possible. Advantages of integrity constraints over alternatives for enforcing data integrity include:
Because you define integrity constraints using SQL statements, no additional programming is required when you define or alter a table. The SQL statements are easy to write and eliminate programming errors.
Integrity constraints are defined for tables and are stored in the data dictionary (see "Overview of the Data Dictionary"). Thus, data entered by all applications must adhere to the same integrity constraints. If the rules change at the table level, then applications need not change. Also, applications can use metadata in the data dictionary to immediately inform users of violations, even before the database checks the SQL statement.
You can disable integrity constraints temporarily to avoid performance overhead when loading large amounts of data. When the data load is complete, you can re-enable the integrity constraints.
Types of Integrity Constraints >>