Tuesday 21 August 2012

Integrity Rules

  • Integrity rules may sound very technical but they are simple and straightforward rules that each table must follow.
  • These are very important in database design, when tables break any of the integrity rules our database will contain errors when retrieving information.
  • Hence the name "integrity" which describes reliability and consistency of values.
  • there are two types of integrity rules that we will look at:
    • Entity Integrity Rule
    • Referential Integrity Rule

Entity Integrity Rule: 

  • The entity integrity rule refers to rules the primary key must follow. 
    • The primary key value cannot be null.
    • The primary key value must be unique.
  • If a table does not meet these two requirements, we say the table is violating the entity integrity rule.
  • The team table violates the entity integrity rules at two places. 
    • Team Super- missing primary key
    • Super Ultra Mega Team and Best Team in the World -has the same primary key. 

Referential Integrity Rule: 

  • The referential integrity rule refers to the foreign key.
  • The foreign key may be null and may have the same value but:
    • The foreign key value must match a record in the table it is referring to.
  • Tables that do not follow this are violating the referential integrity rule.
  • The Player table violates the referential integrity rule at these places: 
    • Player P8 and P9 - these players are in teamID T8, which does not exist in the Team Table.

5 comments:

  1. thanks for the information..it makes me understand IR so much..
    keep writing good information..

    ReplyDelete
  2. a very nice post,precise and easy to understand.thanks for that information

    ReplyDelete
  3. Finnaly i gt the answers clearly nice job. Tq

    ReplyDelete
  4. This put it so simple, but helped so much.
    Thank you so much.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete