A constraint is a condition that has to be fulfilled in a given context. Constraints are typically used in databases and programming languages to detect errors, ensure data consistency, accuracy, and to enforce business requirements.
A constraint is a condition that has to be fulfilled in a given context. Constraints are typically used in databases and programming languages to detect errors, ensure data consistency, accuracy, and to enforce business requirements. Constraints are also important in optimization problems. Constraints can be either hard constraints which set conditions for the variables that are required to be satisfied, or soft constraints which have some variable values that are penalized in the objective function if, and based on the extent that, the conditions on the variables are not satisfied.
For example, database constraints can be:
NOT NULL Constraint - a column cannot have NULL value.
DEFAULT Constraint - a default value for a column when none is specified.
UNIQUE Constraint - all values in a column are different.
CHECK Constraint - all values in a column satisfy certain criteria.
Further reading