How to Enforce Entity Integrity

When you insert or update a table row, the database server ensures that the primary key for the table is still valid: that each row in the table is uniquely identified by the primary key.

Example 1

The Employees table in the demo database uses an employee ID as the primary key. When a new employee is added to the table, IQ checks that the new employee ID value is unique, and is not NULL. See Introduction to Sybase IQ > About Sybase IQ > Demo Database > Table Names and Owners for a list of tables in the demo database.

Example 2

The SalesOrderItems table in the demo database uses two columns to define a primary key.

This table holds information about items ordered. One column contains an id specifying an order, but there may be several items on each order, so this column by itself cannot be a primary key. An additional line_id column identifies which line corresponds to the item. The two columns id and line_id, taken together, specify an item uniquely, and form the primary key. This is known as a multicolumn primary key.