A constraint is a rule that the database manager enforces.
There are three types of constraints:
- A unique constraint is a rule that forbids duplicate values in
one or more columns within a table. Unique and primary keys are the supported
unique constraints. For example, a unique constraint can be defined on the
supplier identifier in the supplier table to ensure that the same supplier
identifier is not given to two suppliers.
- A referential constraint is a logical rule about values in one
or more columns in one or more tables. For example, a set of tables shares
information about a corporation's suppliers. Occasionally, a supplier's ID
changes. You can define a referential constraint stating that the ID of the
supplier in a table must match a supplier ID in the supplier information.
This constraint prevents insert, update, or delete operations that would
otherwise result in missing supplier information.
- A check constraint sets restrictions on data added to a specific
table. For example, a check constraint can ensure that the salary level for
an employee is at least $20 000 whenever salary data is added
or updated in a table containing personnel information.