Defining a Cascade Delete Relationship
There's one last relationship you need to define in the Restaurant Database between InvoiceDetails and InvoiceHeaders. The relationship between these two tables requires a Cascade Delete relationship. We want to ensure that when an invoice is deleted in the InvoiceHeaders web table (the one side of the relationship) that all corresponding child records in the InvoiceDetails web table (the many side of the relationship) are deleted.
Follow this procedure to build your Cascade Delete relationship:
- You want to include the InvoiceNumber field in the InvoiceDetails web table, so open the InvoiceDetails web table in Datasheet view and set the focus on the InvoiceDetailsID field. Start the Lookup Wizard by clicking More Fields and then clicking Lookup & Relationship.
- On the first page of the wizard, select the "The Lookup Field To Get The Values From Another Table" option, and then click Next.
- On the second page of the wizard, select the InvoiceHeaders web table, and then click Next.
- On the third page of the wizard, bring over the InvoiceNumber field from the Available Fields list to the Selected Fields list, and then click Next.
- On the fourth page of the wizard, select the InvoiceNumber field in the drop-down list to sort Ascending by that field, and then click Next.
- On the fifth page of the wizard, leave the default options as they are to hide the key column and keep the widths the same. Click Next to go to the final page of the wizard.
- On the last page of the wizard, shown here, name your field InvoiceID and select the Enable Data Integrity option. Select the Cascade Delete option, and then click Finish to complete the new field and relationship.
Out Viewing Web Relationships Limitation
One of the shortcomings of creating relationships in web databases is that you cannot view the Relationships window as you can in client databases. As a result, you cannot run the Relationships Report option to get a nice graphical printout of all the relationships in your web database.
In this tutorial:
- Designing Web Tables
- Working with the Web
- Creating a New Web Database
- Creating a New Empty Web Database
- Creating Your First Simple Web Table by Entering Data
- Creating a Web Table Using Application Parts
- Using Data Type Parts
- Creating Web Tables in Datasheet View
- Choosing Web Field Names
- Understanding Web Field Data Types
- Setting Field Properties for Web Databases
- Creating Calculated Fields
- Defining Field Validation Rules for Web Databases
- Defining a Table Validation Rule for Web Databases
- Defining a Primary Key for Web Databases
- Understanding Other Web Table Properties
- Creating Lookup Fields in a Web Database
- Creating Relationships Using Lookup Fields
- Defining a Restrict Delete Relationship
- Defining a Cascade Delete Relationship
- Using the Web Compatibility Checker
- Analyzing the Web Compatibility Issues Table
- Preparing a Client Database for the Web