Database
  Home arrow Database arrow Page 2 - Referential Integrity Explained: Bonding T...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Referential Integrity Explained: Bonding Tables Together
By: Alf Pedersen
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 11
    2004-11-17

    Table of Contents:
  • Referential Integrity Explained: Bonding Tables Together
  • Examples
  • How is Referential Integrity Maintained?
  • Taking This a Bit Further

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Referential Integrity Explained: Bonding Tables Together - Examples


    (Page 2 of 4 )

    The following example will further clarify this. Take this simple server model:

    Referential Integrity Explained: Bonding Tables Together

    This is a model that should be easy to understand: We have two tables, TRANSACTIONS and ACCOUNTS. For a given account, there may be one or many (or no) transactions. Sounds fair enough: if you are like me, your bank account has far to many transactions each month. OK, I'll be serious again.

    Let's look at it once more. Let's say that the above model is for a bank with lots of accounts and transactions. What if we just deleted all (or just one) accounts?

    We would end up with a lot of transactions, but if we wanted to check out which name each transaction belonged to, we couldn't tell! Referential integrity is broken; it is no longer, as defined above, sound and unbroken.

    It goes without saying that this is a very unhealthy situation for an information system that is relying upon a good database design.

    Referential integrity is a dead serious concept. From the little example above, I'm certain that you can see the dangers of breaking referential integrity. But do you also notice the danger of changing the value of the primary key in ACCOUNTS? Giving an account a new number will just as effectively break the rule of referential integrity as deleting the very same row. That is why it is so important to be absolutely sure when you choose your primary key for ANY table.

    Come to think of it, we are now talking about the subject of another article on my site: Candidate Keys. I consider that a very important article, and it has been published on many prominent sites on the Net. (That does NOT imply that my site is not prominent...). However, the original is on this site. 

    Now let's return to the real subject: How can we enforce referential integrity, or put another way, how can we be sure that referential integrity is maintained?

    More Database Articles
    More By Alf Pedersen


       · This is a strange article. You plug your own site without telling us what the site...
       · You raise some good points. I'm going to follow up with the author on that...
       · Loosah,This is not an article about naming conventions. Frankly, I do not care...
       · The article is presented as "Referential Integrity Explained" - that would, to me,...
       · Quote "The article is presented as "Referential Integrity Explained" - that would,...
     

    DATABASE ARTICLES

    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client
    - ADO`s Stream Object
    - Opening a Record Object Referencing an Open ...
    - Introducing Jasper (SQL Anywhere 10 Beta)
    - Creating a Database Project in VS 2005

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT