Constraint (mathematics)

With constraints ( German " restriction " ), conditions are defined in various programming languages ​​that must be met by the mandatory value of a variable so that the value can be accepted into the system. In database systems, see Constraints active application to the range of values ​​( domain ) limit of a scalar and to check values ​​on its admissibility. In the program analysis using constraints in the analysis of functional programs.

Constraints in programming languages

Constraints help the compiler and the runtime environment, easier to detect programming errors. Suppose a variable Anzahl_der_Personen_im_Aufzug, here is intuitively clear that this variable must not have a negative value, and must not exceed a maximum value.

In the Ada programming language can look like this:

Type Capacity range is 0 .13; Anzahl_der_Personen_im_Aufzug: Capacity: = 15; Here the compiler can immediately recognize that the value 15 is outside the range previously specified condition. If the variable is not restricted, the programmer would have to check for this condition at each change itself.

Constraints in database systems

In database systems work basically the same constraints. Constraints define conditions that must be met when inserting, modifying and deleting records in the database.

Many database systems yet know in addition to the constraints transactions. The combination of these two concepts is very powerful, because by the end of a transaction, all constraints are checked. If this fails a constraint, any changes to the data that have been carried out in this transaction, withdrawn, as they had never been carried out.

Constraints are defined in database systems with integrity constraints.

List of possible constraints in database systems:

  • NOT NULL → the scalar can not be NULL
  • PRIMARY KEY → scalar must be unique and can not be NULL
  • FOREIGN KEY → scalar must be checked for referential integrity
  • UNIQUE → scalar must be unique within the attribute
  • CHECK ( ) → explicit verification statement to the DBMS; on what needs to be checked is defined as an option this statement

Furthermore, there are several types of constraints:

  • Attribute constraints that refer to a single column
  • Relations constraints, refer to several attributes (columns)
  • Named constraints can be manipulated by name
  • Unnamed constraints, obtain a system-generated name

Example: Attribute Constraint

The following example is in PRIMARY KEY to an unnamed constraint and CONSTRAINT persons_fp a named constraint.

CREATE TABLE person (      id PRIMARY KEY,      fingerprint BYTEA persons_fp CONSTRAINT UNIQUE); Example: Relations Constraint

In the following example, it is at CONSTRAINT person_prime a named constraint and UNIQUE ( ) to an unnamed constraint.

CREATE TABLE person (      id SERIAL,      name VARCHAR,      dob DATE,      born_in VARCHAR,      Person_prime CONSTRAINT PRIMARY KEY ( id), UNIQUE ( name, dob, born_in ) ); Constraints in Logistics

A constraint is also used in this case as a constraint on an action taken. A distinction is made according to requirements or requirements and constraints. When the supply of goods and services in logistics give the constraints eg the restrictions that apply when the load in the area of ​​volume or weight of certain trucks.

Constraints in the evolution

In the development constraints involve an evolutionary way, for example due to historical circumstances on the plan.

Constraints in theoretical computer science

In theoretical computer science, and especially in AI research are relational statements that contain free variables, often referred to as a constraint. Then, a variable assignment or interpretation is sought that matches a given set of constraints, hence it satisfies simultaneously.

An example: x is real above y, y is real above z, z is above x ( this constraint set is not satisfiable ).

An assignment that satisfies all constraints, is often referred to as the "model".

Constraints in and-or trees

Add and-or trees to find constraints on the And - node, here are several sub-goals must be conjunctively satisfied in order to meet the main goal.

201155
de