• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Part 8. Managing Your Database > Setting Up Relationships

Setting Up Relationships

With the database for which you want to establish relationships displayed onscreen, click the Relationships button on the Standard toolbar in the main Access window.

The Show Table dialog box opens with the Tables tab displayed. Click the first table for which you want to establish a relationship to select it.

Click the Add button.

A window representing the table you added (here, Artists) is displayed onscreen. To link another table to the one displayed, click it in the Show Table dialog box.


It's much easier to manage a database when you work with several tables rather than one huge file. For example, suppose that you sell products and use Access to track orders, product lists, inventory, and clients. If you stored all that information in one database table, the table would be difficult to work with. If, though, you create tables for each specific task or action and then set up relationships, you'd be able to work with data more easily. For example, you could link the Orders table to the Product table to pull product information. You could also link the Client Information table to the Orders table so that you could access client information as part of the order. To create these types of links, you set up relationships between tables.

Click the Add button.

A window representing the second table you added (here, Product List) is displayed onscreen. Click the Close button in the Show Tables dialog box to close it.

In the first table window, click the field you want to use to establish a relationship (here, Artist ID) and drag it to its matching field in the second table window.

The Edit Relationships dialog box opens; in it, you can set options on how the relationship you've established will work. Make sure that the correct fields are listed as the linked fields.


Sharing Fields

To set up relationships between tables, the tables must share one field in common. Usually this is some type of unique ID field. The field does not have to have the same name but must contain the same data type and data.


Resizing the Table Window

If necessary, resize the table windows to better view all the fields each one contains. To do so, put the pointer on the border of the field list and drag.


Removing a Table

If you add a table to the Relationships window by mistake, you can remove it from the window by right-clicking the table window and choosing Hide Table from the shortcut menu that appears.

If you want to enforce referential integrity, click the Enforce Referential Integrity check box to select it.

The Cascade Update Related Fields and Cascade Delete Related Records check boxes become available; if desired, mark one or both check boxes.

Click the Create button.


Understanding Referential Integrity

When you turn on referential integrity, Access keeps the related tables in sync. That means if you mark the Cascade Update Related Fields check box and make a change to the related field in one database table, the change will also be made in the related database table. Likewise, if you mark the Cascade Deleted Related Records check box and delete a record in one table, any associated records in the related table are deleted as well.

Access establishes the relationship. A line links the two related fields in the Relationships window. (If you enabled referential integrity, the line indicates this with a chain link symbol.)

Click the Save button to save the relationship.

Click the Close button in the Relationships window to close it.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint