About the Entity Constraints Form

An administrator can create a Check Constraint for any field in the table (but not for any virtual fields, such as Calculated or Computed fields; see Virtual Field Tab for details). A Check Constraint is a table-level constraint that enforces consistency for records at the database table.

Unlike field validation that occurs within the user interface, a Check Constraint prevents a record from being saved within the database if a field's value does not correspond to a value or range specified by constraint.

Constraints Record

The Constraints form can be opened from the Constraints tab in an Entity record.

The Constraints form has the following fields:

Name (Required)

This is the name of the constraint. The name cannot contain spaces. Note that this field cannot be modified for an existing constraint.

Base Table (Required)

The table to which the system should add this constraint. This must be the table that contains the field or fields referenced in the Constraint Text.

Constraint Text (Required)

The SQL text that defines the constraint. Note that this field cannot be modified for an existing constraint.

Validate Existing Data (Required)

When selected, all existing data is validated against the constraint before the constraint is added to the table. Note that this field cannot be modified for an existing constraint.

Not For Replication (Required)

When selected, this constraint is not enforced during replication. Note that this field cannot be modified for an existing constraint.

Is Active (Required)

This field is unavailable for new constraints. A constraint is automatically marked as Active when the entity is saved. This is the only field that can be modified for an existing Constraints record; an administrator can select or clear this option to enable or disable a constraint, as necessary.

Failure Message (Required)

This field specifies the error message that displays to the user when a save operation fails because the record does not comply with this constraint. This field is only valid if Validate In GE is selected. In other words, the specified failure message only appears if the constraint fails at the GE level.

Notes Concerning Entity Constraints

  • Constraints can be enabled or disabled, but once created, it cannot be modified. To change an existing constraint, delete it and then add a new one.
  • When a user creates a constraint and then saves the Entities record, Aptify creates a Check Constraint in the database table. This constraint also becomes visible within the table's properties in Microsoft SQL Server Management Studio.

SQL Server Check Constraint

  • While a Check Constraint ensures integrity at the database level, validating data against a constraint requires a trip to the database. A developer or administrator can use a combination of field-level validation (as specified on a field's Validation tab) and entity constraints to ensure database consistency while attempting to catch user validation errors at the user interface before accessing the database.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.