Constraints enable you to reduce data entry errors by verifying data before inserting it into a table. Define constraints on schema tables and columns from the Manage & Monitor tab.

You can create constraints when you create a table, or you can add them later. You can create the following types of constraints.

Check constraint. Limits the values or value range that can be inserted in a column.

Unique constraint. Ensures that a column or set of columns is unique.

Primary key constraint. Uniquely identifies each row in a table. There can be only one primary key per table.

Foreign key constraint. Points to a primary key in another table.

You enter SQL fragments to define a constraint.

You are logged in to your organization as an organization administrator or user with database privileges.

The table on which to create the constraint already exists.

You expanded the schema in the left pane, then selected Tables.

The middle pane shows the Tables pane.

1

In the left navigation pane, expand the schema that contains the table for which you want to create a constraint.

2

Click Tables. The Tables page appears in the middle pane with a list of the schema's tables.

3

Click the table to select it, then click the gear icon. The Actions drop-down menu appears.

4

Select Create > Constraint. The Constraint drop-down menu appears.

5

Click the type of constraint you want to create. A Constraint dialog appears.

6

Complete the dialog as appropriate for the constraint you're creating, then click OK.

Data Director creates the constraint.

Check constraints evaluate to a Boolean value. Use check constraints to check whether or not a value entered for a column meets a specific truth-type requirement. For example, suppose that you create a column that must be a positive integer, such as a product price. You can create a check constraint to return TRUE when the product price is greater than 0, and to return FALSE when the product price is less than 0. The check constraint ensures that if a user tries to enter a negative product price, the data entry operation fails with a SQL error.

Enter a check constraint as follows.

1

In the Constraints tab, select Check from the drop-down menu, and click Create.

2

Enter a name for the constraint, such as check_positive_price, in the Name field.

3

Enter the constraint in the Check field. The constraint should be a simple equation; you do not have to enter SQL. For example, product_price > 0.

4

Optionally enter a comment that describes the constraint.

5

Click OK. Data Director creates the constraint.