So, what is Referential Integrity? Referential Integrity ensures (Web hosting directory)

So, what is Referential Integrity? Referential Integrity ensures the integrity of relationships between primary and foreign key values in related tables. Most relational database engines use what are often called constraints. Primary and foreign keys are both constraints. Remember, a constraint is a piece of metadata defined for a table defining restrictions on values. A primary key constraint forces the primary key field to be unique. A primary key constraint is also forced to make checks against any foreign key constraints referenced back to that primary key constraint. Referencing (or referential) foreign key constraints can be in any table, including the same table as the primary key constrained field referenced by the foreign key (a self join). A foreign key constraint uses its reference to refer back to a referenced table, containing the primary key constraint, to ensure that the two values in the primary key field and foreign key field match. Simply put, primary and foreign keys automatically verify against each other. Primary and foreign key references are the connections establishing and enforcing Referential Integrity between tables. There are some specific circumstances to consider in terms of how Referential Integrity is generally enforced: A primary key table is assumed to be a parent table and a foreign key table a child table. . When adding a new record to a child table, if a foreign key value is entered, it must exist in the related primary key field of the parent table. Foreign key fields can contain NULL values. Primary key field values can never contain NULL values as they are required to be unique. . When changing a record in a parent table if the primary key is changed, the change must be cascaded to all foreign key valued records in any related child tables. Otherwise, the change to the parent table must be prohibited. The term cascade implies that changes to data in parent tables are propagated to all child tables containing foreign key field copies of a primary key from a parent table. . When changing a record in a child table, a change to a foreign key requires that a related primary key must be checked for existence, or changed first. If a foreign key is changed to NULL, no primary key is required. If the foreign key is changed to a non-NULL value, the foreign key value must exist as a primary key value in the related parent table. . When deleting a parent table record then related foreign key records in child tables must either be cascade deleted or deleted from child tables first. Understanding Indexes Indexes are not really part and parcel of the relational database model itself; however, indexes are so important to performance and overall database usability that they simply have to be introduced without going into the nitty-gritty of how each different type of index functions internally. It is important to understand the fundamentals of indexes and their different types and attributes to get a basic understanding as to why exactly indexing is so important for relational databases in general. 64 Chapter 3
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Leave a Reply