What is Referential Integrity

  • Thread starter Thread starter roland
  • Start date Start date
The term refers to the rules about relationships between tables. For
example, if you declare a field as a foreign key, any values you enter into
it must exist in the source table.

HTH

--
Rebecca Riordan, MVP

Designing Relational Database Systems
Microsoft SQL Server 2000 Programming Step by Step
Microsoft ADO.NET Step by Step

http://www.microsoft.com/mspress

Blessed are they who can laugh at themselves,
for they shall never cease to be amused...
 
(Note: It's better to state your question also in the body of your
message, not just in the subject.)

Referential integrity is the assurance that all references between
related tables are intact; that is, if table A is related to table B by
having a field in A that contains the key of a record in B -- what's
called a "foreign key" field -- then if referential integrity is
enforced, it is guranteed that there is in fact a record in B with that
key. One cannot delete the record from B without also deleting the
record from A, nor change the key of the B record without also changing
the foreign key in the A record; otherwise, the record in A would have
a reference to a "B" record that does not exist.

In a relationship with referential integrity enforced, the database
engine will not permit you to "orphan" any record in table A by deleting
its parent record in B. You *may* define the relationship to "cascade
deletes" and/or "cascade updates", in which case the database engine
itself will automatically delete or modify the related record(s) in
table A if you delete or change the key of a record in table B. If you
don't cascade deletes or updates, you must first make the necessary
changes to table A before you make the updates to B, or they will simply
be rejected. In this way, the database engine guarantees that all
references between these tables are valid at all times.
 
On Wed, 19 Nov 2003 09:58:30 -0800, "roland"

Referential integrity is a jargon term for:

Make sure that when you have two tables containing related
information, that the data in the two tables is in fact connected.

As an example, suppose you had an address table, and a table of Zip
Codes. If you have Referential Integrity (or Relational Integrity,
both terms are used) set between the table, you would not be able to
enter an address into the table if it had a nonexistant zipcode -
you'ld get an error message.
 
Back
Top