Microsoft Access 2010 Bible

(Rick Simeone) #1

Part I: Access Building Blocks


120



  1. Select Database Tools ➪ Relationships.


The Relationships window appears.



  1. Click on the Show Table ribbon button, or right-click on the Relationships window and
    select Show Table from the shortcut menu. The Add Table dialog box appears, as shown
    in Figure 3.14.


FIGURE 3.14
Double-click to add tables to the Relationships window.


  1. Add tblBookOrders5 and tblOrderDetails to the Relationships window (double-
    click each table in the Show Table dialog box, or select each table and click the Add
    button).

  2. You create a relationship by dragging the primary key field in the one-side table and
    dropping it on the foreign key in the many-side table. Alternatively, drag the foreign key
    field and drop it on the primary key field.


For this example, drag OrderID from tblBookOrders5 and drop it on OrderID in
tblBookOrderDetails. Access immediately opens the Edit Relationships dialog box
(shown in Figure 3.15) to enable you to specify the details about the relationship you
intend to form between the tables. Notice that Access recognizes that the relationship
between the tblBookOrders5 and tblBookOrderDetails as a one-to-many.



  1. Specify the referential details you want Access to enforce in the database.


In Figure 3.15 notice the Cascade Delete Related Records check box. If this check box is
left unchecked, Access will not permit you to delete records in tblBookOrders5 (the
one-side table) until all the corresponding records in tblBookOrderDetails (the
many-side table) were first deleted. With this box checked, deletions across the relation-
ship “cascade” automatically. Cascading deletes can be a dangerous operation because the
deletions in the many-side table occur without confirmation.

Free download pdf