constraint

A rule the database enforces on stored data, such as a column that must be unique or not null.

In more detail

Constraints protect data even from programs that skip application checks. Common examples are primary keys, unique columns, foreign keys and not-null columns.

Example

In this course: A test that inserts a row, then a second row that breaks the rule, and expects the database to reject it proves the constraint really exists. Fakes and in-memory stand-ins usually do not enforce constraints, which is why this belongs in a real database test.

Related terms

Taught in

References