Types of Relationships

Diving Line


If you need to print this page out, type your name in the box below.

Your Name : 


Information

Data is shared between different tables using a Relationship.

Relationships can be created between two tables using the Primary Key and Foreign Key fields.

In our example, the customer table has a Primary Key called CustomerID.

The orders table has a Foreign Key also called CustomerID.

We created a relationship between these two fields so the CustomerID number from the customer table can be shared with the CustomerID field in the Orders table.

IMAGE HERE


We did the same between the Orders table and the Products table.  The Products table has a Primary Key called ProductID.  The Orders table has a Foreign Key also called ProductID.  

We created a relationship between these two fields so the ProductID number from the product table can be shared with the ProductID field in the orders table.

IMAGE HERE


Information

There are three types of relationships we can create in a database.

One to One Where both tables only have one record
One to Many Where the table with the primary key has only one record that relates to many records in the other table
Many to Many Where each record in the primary key table relates to many records in the other table


PrintIT  Print out this Page

Next  Querying Data



Last modified: Monday, 7 December 2020, 2:58 PM