Java Reference
In-Depth Information
This completes the table definitions required to implement the requirements of the
LEDES specification. The next step is to ensure that the referential integrity
requirements of the database have been met.
Referential Integrity
In addition to the definitions of the normal forms, the relational model defines certain
integrity rules that are a necessary part of any relational database. There are two
types of integrity rules: general and database-specific .
General Integrity Rules
The relational model specifies these two general integrity rules that apply to all
databases:
 
Entity integrity rule
 
Referential integrity rule
The entity integrity rule states that primary keys cannot contain NULLs. Obviously,
you can't use a NULL to uniquely reference a row, so this is just common sense. It's
important to note that, if you use composite keys, this rule requires that none of the
individual columns making up the composite key contain NULLs. Most databases
enforce this rule automatically when a primary key is declared.
The referential integrity rule states that the database must not contain any unmatched
foreign-key values. In other words, all references through foreign keys must point to
primary keys identifying rows that actually exist.
The referential integrity rule also means that corrective action must be taken to
prevent changes or deletions to a row referenced by a foreign key leaving that foreign
key with no primary key to reference. This can be handled in the following ways:
 
Such changes can be disallowed.
 
Changes can be cascaded, so that deleting a row containing a referenced primary key results in
deleting all linked rows in dependent tables.
 
The dependent foreign-key values are set to NULL.
The specific action you take depends on the circumstances. Many relational
database systems support the automatic implementation of one or more of these
ways of handling attempted violations of the referential integrity rule. For example, an
attempt to insert a row with a foreign key that cannot be found in the appropriate table
results in a SQL exception message such as the following:
INSERT statement conflicted with COLUMN FOREIGN_KEY constraint
'FK_CONTACTS_ADDRESS_INFO'. The conflict occurred in database 'LEDES',
Search WWH ::




Custom Search