Friday, March 10, 2017

What is the Relationships window?

What is the Relationships window?

The Relationships window lets you define relationship between items stored in multiple Access tables. It is available by clicking Database Tools > Relationships.

The Relationships button on the Database Tools tab

Relationships are like the rules that govern how data is connected in your database. In a well-normalized order-processing database, for example, most likely you'll have customer information in one table and order information in another table. You want to make sure customers don't get separated from their orders, right? And you don't want an order to be created that doesn't have a valid customer connected to it. The Relationships window is where you go to set these rules so that they apply throughout your database.

If you've built an Access query before, you'll notice that the Relationships window looks a lot like the top part of the Query Builder:

The Access Relationships window

In the Relationships window, you use the commands on the Design tab to add tables to the view, and then you drag fields between tables to set up the relationships. In this example, the relationship allows for multiple orders to be connected to each customer, but it keeps you from creating an order for a customer that doesn't exist. Once you set up these rules in the Relationships window, they'll apply to the whole database (for example, if you create a new query, the joins will automatically be set up according to your relationship rules).

Note:  Deleting a table from the Relationships window won't delete it from your database, nor will it remove relationships that you've already established.

Things you can do

Task

How to do it

Add a table or query to the window

Click Design > Show Table, select the table or query you want, and then click Add.

Delete a table or query from the window

Select the table or query, and then press DELETE.

Hide a table or query

Right-click the table or query, and then click Hide Table.

Create a relationship

Drag a field from one table or query to the corresponding field in the other table or query.

Set properties for a relationship

Right-click the relationship line between two tables (this can take a few tries to hit it exactly right), and then click Edit Relationship.

Delete a relationship

Right-click the relationship line between two tables (this can take a few tries to hit it exactly right), and then click Delete.

Show all relationships

Click Design > All Relationships.

View the relationships for a particular table

Select the table, and then click Design > Direct Relationships.

View the relationships for one table without viewing the relationships for other tables

Click Design > Tools > Clear Layout. Add the table you want to see relationships for (Design > Relationships > Show Table), and then click Design > Relationships > Direct Relationships.

Now that you're up to speed on the Relationships window, learn how to create, edit or delete a relationship.

No comments:

Post a Comment