SIUe logo

Connie S. Barber

School of Business

Assistant Professor

Department of Computer Management & Information Systems

Unit 3.4: Setting up relationships

Setting up relationships

Now that the tables are imported and the data types set for all fields, the next step is to set up the relationships between the tables. Two important points to keep in mind:
  • All tables need to have a primary key. This should have been established when the data was imported. Review each table to be sure that there is a primary key assigned. If the primary key is not assigned do the following while in design view of the table:
  • Click on the grey box to the left of the field that is to be the primary key
  • Click on the primary key button on the ‘Table Tools’ -> ‘Design’ ribbon shown here
  • Data types must be the same for fields when used as the primary key and the foreign key. In the example below, VetClinID is the primary key in the Vet Offices table and a foreign key in Vets table.
  • So, in order for the relationship to be established between the tables, the data type has to be the same for the VetClinID field in both tables, as is shown in the image below.
  • Once you have verified that all tables have a primary key and that when used as a foreign key the fields have matching data types, you are ready to set up the relationships. This document, Menagerie Kennel relationships_ shows how the tables are to be related inside the database. Use that visual representation of the relationships as a guide and follow the steps outlined in the setting up relationships in Menagerie Kennel document.