A declarative mechanism such as a check or foreign key that enforces some data integrity rule in a database.
Database management systems can enforce various types of declarative constraints that assert certain invariants on the data in the database, rejecting attempts to enter data that violates those constraints. The constraints apply and maintain data integrity rules on the data contained. Some types of constraints are:
Foreign keys constrain values in database columns to values present in a reference table.
Check constraints Apply a logical condition on one or more columns and reject any rows that cause the condition to evaluate to false.
Not Null constraints Require a column to contain a value.
Unique constraints Require a column or columns to contain a unique value or combination of values, so that no two rows can have the same set of values.
Primary keys are a specific constraint intended to guarantee uniqueness of the identifying column or columns of a table.
Column defaults are values that are entered if a row is entered into the database without a value specified for that column.