Exploring Microsoft Access Chapter 6 Many-to-Many Relationships: A More Complex System
Objectives (1 of 2) Define and explain a many-to-many relationship Use Cascade Update and Cascade Delete Explain how the AutoNumber field simplifies entering new records
Objectives (2 of 2) Create a main farm and subform based on a query Create a parameter query Use aggregate functions Use Get External Data command
Overview (1 of 2) More database design practice Extends relational database concepts including one-to-many and many-to-many relationships Use AutoNumber to simplify record creation
Overview (2 of 2) Extends subform and query information from related tables Create forms based on multiple-table queries Create a parameter query Create queries with built-in aggregate functions
Many-to-Many Relationships A many-to-many relationship requires an additional table that has a one-to-many relationship to each of the related tables The primary key of the additional table is the combination of the primary keys of the related tables
Implementing Many-To-Many Relationships Many-to-many relationship is implemented by a pair of one-to-many relationships Enforce Referential Integrity is selected Cascade Delete Related Records is selected
Referential Integrity Ensures records in related tables are consistent with one another Prevents adding a record to a related table with an invalid foreign key Prevents deleting a record in the primary table when there are corresponding records in the related table
Cascaded Deletion When a record in the primary table is deleted, Access simultaneously deletes the corresponding records in the related table
Cascaded Updating When the primary key in the primary table is updated, Access automatically updates the value in the corresponding records in the related table
Subforms, Queries, and AutoLookup Main and subforms based on queries: - display of information from multiple tables - display records other than by primary key AutoLookup will find corresponding data after unique ID is entered
Main Form and Subform Main form has fields from Orders and Customers tables Subform has fields from Order Details and Products tables
Designing a main and subform Main form Detail Subform Detail
Parameter Queries Prompts the user for criteria when executed The prompt is enclosed in square brackets in the query design grid A parameter query may prompt for any number of variables
Parameter Query Enter the prompt in square brackets in the Criteria field Users are prompted with a dialog box when the query is executed
Total Queries Total Queries perform calculations on a group of records Total row – Contains either Group by or aggregate entry Group By – Records in the dynaset are to be grouped according to the like values Sum Function – Specifies math to be performed on that field for each group of records
Adding Tables Existing tables and relationships are unaffected by addition of new table
Chapter 6 Summary (1 of 2) A many-to-many relationship requires an additional table Many-to-many is implemented with a pair of one-to-many relationships Enforce referential integrity to prevent errors Base forms and subforms on queries
Chapter 6 Summary (2 of 2) Parameter query uses prompts Aggregate functions perform calculations on groups of records New tables may be added at any time without affecting data in the existing tables