DELAPARRA
Index
Color
NL
Category: Programming paradigms

Constraint

Explained by Updated

What is Constraint?

Constraint: A restriction a solution must satisfy, e.g. "x + y = 10" or "no two employees share a shift". A constraint is a rule that any valid solution must satisfy. "Each employee works at most five shifts a week" and "two meetings may not overlap in the same room" are constraints.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Constraint

How is Constraint used in practice?

The term shows up in two places developers meet often. In constraint programming, you describe the rules and let a solver find solutions. In databases, constraints such as NOT NULL, UNIQUE, foreign keys and CHECK enforce rules on the data itself.

What should you keep in mind with Constraint?

Database constraints are worth using even when your application already validates input. Validation can be skipped by a bug, a script or a direct database change. A unique constraint on an email column guarantees there are no duplicates, however the data arrives. It is the last line of defence for data you cannot afford to get wrong.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with C

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.