Contents Index Enforcing entity and referential integrity If a client application breaches entity integrity

ASA SQL User's Guide
  Ensuring Data Integrity
    Enforcing entity and referential integrity

Enforcing entity integrity


When a user inserts or updates a 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 employee table in the sample database uses an employee ID as the primary key. When you add a new employee to the table, the database server checks that the new employee ID value is unique and is not NULL.

Example 2 

The sales_order_items table in the sample 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 columns id and line_id, taken together, specify an item uniquely, and form the primary key.


Contents Index Enforcing entity and referential integrity If a client application breaches entity integrity