Progress
Embedded SQL-92
Guide and Reference


Need for Integrity Constraints

Integrity constraints are necessary because data in a database must be valid and consistent at all times. Data might be inconsistent because of entry errors, duplicate entries of rows, or other violations.

To illustrate, consider a table containing employee information where the employee numbers must be unique. To ensure this, specify a UNIQUE constraint on the column that contains the employee number (emp_no):

EXEC SQL 
     CREATE TABLE employee_info ( 
          emp_no      INTEGER NOT NULL UNIQUE, 
          first_name  VARCHAR(20) NOT NULL, 
          last_name   VARCHAR(20) NOT NULL, 
          title       VARCHAR(20) 
     ) ; 

See the "Candidate Keys" section for information on the UNIQUE keyword.

Similarly, for each order entry made in an orders table, you might want to ensure that the associated item entry is present in another table by specifying a referential integrity constraint on a column in the orders table. See the examples in the "Referential Constraints" section later in this chapter.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095