1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

why we should introduce the referential integrity before the data entered?

Discussion in 'Database' started by go4expert, Jun 1, 2005.

  1. go4expert

    go4expert Moderator

    why we should introduce the referential integrity before the data entered?
     
  2. shabbir

    shabbir Administrator Staff Member

    The one and the only reason that we should introduce the referential integrity before the data entered so that the whatever data has been entered also follows the same referential integrity.

    If we take an example it will be much clearer

    Employee
    --------
    EmpId
    Name
    Address
    DeptId

    Department
    ----------
    DeptId
    DeptName

    Case 1:
    ------
    Now there is no referential integrity initially and there is no data as well.

    Say now I would like to insert a new employee. Then as there is no data in the department table the employee can only be in on department but if we dont have the referential integrity a situation may come where there is no valid department for the employee.

    Case 2:
    ------
    Now there are some Departments and some employees. Then when I mistype a department then again the employee goes into a no department situation.

    If we dont have the tables as empty and would like to put the referential integrity on the existing data there can be situation where they will not follow the referential integrity and so Habraken, suggest that one should probably set up relationships and enforce referential integrity before one tries to enter any data in the related tables.
     

Share This Page