Share this Page URL

Chapter 3. Managing the Consistency, For... > Table Relationships and Referential ... - Pg. 75

Managing the Consistency, Format, and Integrity of Your Data 75 you could be left with a group of expenses that have no reference. The campaign ID for the deleted campaign, used as a foreign key in the CampaignExpenses table, wouldn't match a primary key in the MarketingCampaigns table. Even with a relationship between the two tables, you wouldn't be able to match the expenses with a marketing campaign. To avoid this situation and others like it (for example, a set of orders with no matching customer), Access can apply a set of rules known as referential integrity to ensure that the records in related tables stay intact. In the following steps, we'll look at referential integrity in action and examine some of its rules in the process. Enforce referential integrity 1. 2. 3. Start Access, and open the HelloWorld3.mdb database, located in theChap03 subfolder in the folder where you copied this book's sample files. In the Database window, click Tables in the Objects list, select the table named Compensation, and then click Open on the Database window toolbar. Click in the EmployeeID field in the blank new record (the last row of the table), enter 10, and then enter whatever data you want for the Salary, PerformanceRating, and Bonus fields. After entering an amount in the Bonus field, press Tab. You should see the following error message: