Wednesday, January 27, 2010

CONSTRAINT


Share/Save/Bookmark
In the object hierarchy under any table, you will find Constraints. Constraints can be added by selecting ADD TABLE CONSTRAINT from the Constraints context menu. Once a constraint has been created, it can also be commented on and dropped. This section describes how to create, comment on, and drop a constraint with RHDB Administrator.
Constraints are not actual entities themselves (except for check constraints). Constraints are mostly a collection of indexes and triggers that restrict certain actions on a table. There are four types of constraints:
Primary Key Constraints
Unique Constraints
Check Constraints
Foreign Key (FK) Constraints.
The following sections describe each of these constraints in brief and provide an example of how to create them. Note that all of these examples are based on the table invoices

Primary Key Constraints

A primary key is a type of index that will most likely be used as the primary index when a query is made on the table (assuming of course, that one of the conditional fields in the query pertains to the column on which the index exists).

Unique Constraints

Unique constraints may be placed on multiple columns. They constrain the UPDATE/INSERTS on the table so that the values being updated or inserted do not match any other row in the table for the corresponding values.

Check Constraints

A check constraint prevents updates/inserts on the table by placing a check condition on the selected column. The UPDATE/INSERT is allowed only if the check condition qualifies.

Foreign Key (FK) Constraints

A foreign key constraint allows certain fields in one table to refer to fields in another table. This type of constraint is useful if you have two tables, one of which has partial information, details on which can be sought from another table with a matching entry. A foreign key constraint in this case will prevent the deletion of an entry from the table with detailed information if there is an entry in the table with partial information that matches it.

from : www.redhat.com

0 comments:

Post a Comment