Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Referential integrity is a system of rules that ensure relationships between rows in related tables are valid and that you do not accidentally delete or change related data.
Procedure
You can set referential integrity when all of the following conditions are met:
- The matching column from the primary table is a primary key or has a unique constraint.
- The related columns in the foreign table have the same data type and size.
When referential integrity is enforced, you must observe the following rules:
- You cannot enter a value in the foreign-key column of the related table if that value does not exist in the primary key of the related table. However, you can enter a null in the foreign-key column. For example, you cannot indicate that a job is assigned to an employee who is not included in the
employeetable, but you can indicate that an employee has no assigned job by entering a null in thejob_idcolumn of theemployeetable. - You cannot delete a row from a primary key table if rows matching it exist in a related table. For example, you cannot delete a row from the
jobstable if there are employees assigned to the job represented by that row in theemployeetable. - You cannot change a primary key value in the primary key table if that row has related rows. For example, you cannot change a row's
job_idvalue in thejobstable if there are employees with thatjob_idin theemployeetable.
See Also
Other Resources
Foreign Key Relationships Dialog Box (Visual Database Tools)
Working with Relationships (Visual Database Tools)