You are on page 1of 25

Microsoft

Access
Create Relationships for a new
database
Lecture 6

Dr. Huynh Tan Quoc

Business Computing Skills - BA120IU 1-1


Course goals

• Create a one-to-many relationship.


• Set referential integrity.
• Create lookup fields.

1-2
Create relationships

You create relationships by using a


field from one table as a field in a
related table.

Primary and foreign keys in a table structure.

1-3
Create relationships

1 The field you include is your


primary key. Each of the tables in
your database has a primary key,
and you include it as a new field in
another table to create a
relationship with that other table.

Primary and foreign keys in a table structure. 2 When you share a primary key, the
new field in the second table is
called a foreign key.

1-4
Create relationships
This course shows you how to
create that type of relationship and
how to set rules that control how
you can update and delete the data
in your database.

Primary and foreign keys in a table structure.

1-6
Types of relationships
Your tables can participate in three
types of relationships, as shown in
the picture:

1 You have a one-to-one


relationship when a single record in
one table is related to a single
record in another table, and vice
The three types of table relationships: one-to-one,
one-to-many; and many-to-many. versa.

2 You have a one-to-many


relationship when one record in a
table is related to many records in
another table.
1-7
Types of relationships
3 You have a many-to-many
relationship when several records
in one table are related to several
records in another table.

The three types of table relationships: one-to-one,


one-to-many; and many-to-many.

1-8
Creating a Relational Database

Point to the bottom of the video to see the video controls. Drag or point along the progress bar to
move forward or go back. 1-10
Creating a Relational Database
Create a relational database that will be used to keep track of a music collection.

1-11
Creating a Relational Database

1-12
Creating a Relational Database

1-13
Set referential integrity

Point to the bottom of the video to see the video controls. Drag or point along the progress bar to
move forward or go back.
1-14
Creating a Relational Database

Choose the CDS table and the SONGS table to add them both to the relationships window.

1-15
Creating a Relational Database
Relationships window.

Click on CD# in the CDS table and drag it on to CD# in the SONGS table.

1-16
Creating a Relational Database
A line will appear to indicate the relationship

1-17
Creating a Relational Database
Enter the following record in the CDS table and SONGS table

When you finish entering the record, a + sign will appear to the left of the record.

1-18
Creating a Relational Database
Enter the following record in the SONG table

1-19
Creating Lookup Lists
Enter the following records in CD types and GENRES types

1-20
Creating Lookup Lists

Point to the bottom of the video to see the video controls. Drag or point along the progress bar to
move forward or go back. 1-21
Creating Lookup Lists

• Open the CDS table in design view.


• Select the CD Type field.
• From the list of field data types,
choose Lookup Wizard as shown to
the right. The Lookup Wizard will
start.

1-22
Creating Lookup Lists
Select the Table: CD TYPES

1-23
Creating Lookup Lists
Select the CD TYPES field

1-24
Creating Lookup Lists
Choose to have the CD Types sorted in alphabetical order

1-25
Creating Lookup Lists
Click FINISH to create a relationship between the CDS & CD TYPES tables.

1-26
Checking Lookup Relationships
Select Database Tools from the Ribbon and click the Relationships icon.

1-27

You might also like