Share via

What is enforce referential integrity?

Anonymous
2011-04-10T09:39:55+00:00

What is enforce referential integrity?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. HansV 462.6K Reputation points MVP Volunteer Moderator
    2011-04-10T10:06:39+00:00

    Let's take a simple example from the Northwind sample database.

    You have a table Customers with primary key CustomerID, i.e. each customer is uniquely identified by its CustomerID.

    You have another table Orders with primary key OrderID. Each order is for a specific customer, so the Orders table contains a field CustomerID. CustomerID is not unique in this table, for one customer can have several orders.

    In the Relationships window, you can create a link between the two tables on the CustomerID field. If you do not enforce referential integrity for this relationship (link), it is possible to enter a non-existing CustomerID in the Orders table. It is also possible to delete a customer from the Customers table that has some orders in the Orders table, leaving those orders orphaned since their CustomerID is no longer valid.

    By ticking the check box "Enforce Referential Integrity" in the properties of the relationship between Customers and Orders, you make it impossible to enter an invalid CustomerID in the Orders table. And you can't delete a customer that has orders, unless you also tick the check box "Cascade Delete Related Records" in the properties of the relationship. If you do that, deleting the customer will also delete all its orders. This can be useful, but also dangerous, so you should only tick "Cascade Delete Related Records" if you're aware of the consequences.

    4 people found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-04-11T07:32:14+00:00

    Thanks

    0 comments No comments
  2. Anonymous
    2011-04-11T07:30:13+00:00

    Thanks

    0 comments No comments