Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- dBsee 4.6 - The Library - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

   When a relation between two files is set up on a common field, this field
   will be called Primary Key in the parent file while the same field in
   the child file will be called Foreign Key. The fundamental difference
   between a Primary and a Foreign key is the fact that the Primary key on
   the parent file must be unique, i.e. able to identify each record
   uniquely. The Foreign key in the child file may not have this property.

   The foreign key can be defined as the field or combination of fields whose
   value must also correspond to the primary key.

Example:

   If a 1:N relation is set between the Customers file and the Orders file on
   the common field Customer Code (CusCode), this field, on which an index
   must be defined, will become the foreign key in Orders and the primary key
   in Customers.

   When a record is added to the child file, a link between the child file's
   and the parent file's record is created. If a record in the parent file is
   deleted, the records in the child file that refer to it will then have a
   link with a record that no longer exists. The integrity of the data,
   therefore, is lost.

   The referential data integrity is a form of integrity that allows to treat
   the database as a single unit, and not as if it was made up of a group of
   distinct files. The referential data integrity can be defined with this
   rule: if a file ownes a foreign key, this key must be either null or
   equal to the primary key of another file.

   To set the referential integrity it is necessary to establish, for each
   relation, the rule to follow for when the primary key is modified or when
   a record is deleted. Five methods of action exist:

Restrict

   Access to the primary key is denied if there are foreign keys with the
   same value.

   It is not possible to modify or delete a Customer that has one or more
   orders associated to it.

Nullify

   The foreign keys that have the same value of the primary key will be given
   a null (empty) value.

   When a Customer is modified or deleted, the orders associated to it will
   be given the null value. It will then be possible to immediately recognise
   the orders not associated to any Customer.

Cascade

   The intervention made on the primary key will also be extended to the file
   in relation to the main file.

   The modification made on the Customer code is also made on all of the
   Customer's orders. If the Customer is deleted, all the orders associated
   to the Customer will also be deleted.

Prevent

   The Prevent mode prohibits all interventions on the primary key.

   A Customer cannot be deleted. This is independent from the fact that the
   Customer may or may not have orders. The two files must be related with a
   1:N relation with the Prevent options activated.

Orphan

   The intervention on the primary key is done without verifying the
   existence of a foreign key, creating therefore "orphans".

   No control is made. Orders that refer to non existing Customers can
   therefore exist.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson