Editing Relationships
Now that the tables have been created, the
relationships between the tables have to be specified.
- The main dialog should display all the tables that have been
created. If the dialog does not display all the tables, click on the table
option and create the missing tables.
- On the main menu choose the Tools option and then click on
Relationships . This
will bring up the Show Table dialog. Highlight all the tables. Click on
Add, this will add the tables to the relationship. Then click Close, this
will close the Show Table dialog.
- View the Relationship window. The primary keys for all the tables
appear in bold.
- We will set the relationship between the
Student table and Takes table. Double click on SSN in the Student table,
this will bring up the Edit Relationships dialog.
Click on Create New. Create New allows you to
specify the table and the table entries for creating the relationship.
Choose Student as the left table and Takes as the
right table. Within the table choose SSN as the left column name and SSN as the
right column name. Click on OK. The Student table is related to the Takes table.
- This brings up the Edit Relationship dialog. In the Edit dialog
choose the Enforce Referential Integrity option. There are then two
options.
·
Cascade Update Related Fields – this ensures
that when you change data in the parent table, data corresponding in the child table will be changed/updated also.
·
Cascade Delete Related Records – this will delete data in the child field when the corresponding data
has been deleted in the parent field.
We will not
be using these options. Click on OK.
This sets a One-to-Many
relationship between Students and Takes.
- Set the relationships for the remaining tables, based on the E-R
diagram. Save the relationship diagram. Close the relationship window.
Main | Prev | Next