Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Referential Integrity

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 282
    Comment on it

    Referential Integrity

    Referential Integrity is a concept in which the tables shares a relationship between them and that should be consistent.

    Ex:

    If we have a table called Employee and the other Employee Salary and columns in them of name salary respectively.And we we have given a reference of name to Employee Salary table.

    Now we delete the one entry from the name of Employee table.

    Now we will have to delete the name from the Employee Salary table manually.

    This is really hactic if we have more tables.

    To overcome this we use referential integrity.

    We give the reference of name to Employee Salary table and then use cascading delete that is a constraint to Employee Salary table. Now whenever we delete a name from Employee table it automatically get deleted from the Employee Salary table and other related details too that are in the Employee Salary table.

    There are three type of rules in referential integrity

    1.We may not add a record to the Employee Salary table unless the foreign key for that record points to an existing employee in the Employee table.

    2.If a record in the Employee table is deleted, all corresponding records in the Employee Salary table must be deleted using a cascading delete. This was the example we had given earlier.

    3.If the primary key for a record in the Employee table changes, all corresponding records in the Employee Salary table must be modified using what's called a cascading update.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: