- Why This Chapter Is Important
- Introduction to Relational Database Design
- Establishing Relationships in Access
- Establishing Referential Integrity
- Looking at the Benefits of Relationships
- Examining Indexes and Relationships
- Practical Examples: Establishing the Relationships Between the Tables Included in the Time and Billing Database
The primary benefit of relationships is the data integrity they provide. Without the establishment of relationships, users are free to add records to child tables without regard to entering required parent information. After referential integrity is established, you can enable Cascade Update Related Fields or Cascade Delete Related Records, as appropriate, which will save you quite a bit of code in maintaining the integrity of the data in your system. Most relational database management systems require that you write the code to delete related records when the user deletes a parent record or to update the foreign key in related records when the user modifies the primary key of the parent. By enabling the Cascade Update and Cascade Delete check boxes, you are sheltered from having to write a single line of code to perform these tasks when they are appropriate.
SQL Server 2000 offers Cascade Update and Cascade Delete features similar to those found in Microsoft Access. This means that you no longer need to write your own T-SQL statements when it is appropriate to implement Cascade Update and Delete functionality.
Access automatically carries relationships into your queries. This means that each time you build a new query, it automatically establishes the relationships between the tables within the query, based on the relationships you have set up in the Relationships window. Furthermore, each time you build a form or report, Access uses relationships between the tables included on the form or report to assist with the design process. Whether you delete or update data using a datasheet or a form, all referential integrity rules automatically apply, even if you establish the relationship after you build the form.