You are on page 1of 34

ParadigmPublishing,Inc.

Content
Content
s

Access 2013
Level 1
Unit 1

Creating Tables and


Queries
Chapter 2Creating Relationships
between Tables

ParadigmPublishing,Inc.

Content
Content
s

Creating Relationships
between Tables
Quick Links to Presentation Contents

Create Related Tables


CHECKPOINT 1
Create a One-to-One Relationship
Display Related Records in a Subdatasheet
CHECKPOINT 2

ParadigmPublishing,Inc.

Content
Content
s

Create Related Tables


Generally, a database management system
fits into one of two categories: either a file
management system (also sometimes
referred to as a flat file database) or a
relational database management system.

ParadigmPublishing,Inc.

Content
Content
s

Create Related Tables continued

Taking time to plan a database is extremely


important.
Creating a database with related tables
takes even more consideration.
You need to determine how to break down
the required data and what tables to create
to eliminate redundancies.

ParadigmPublishing,Inc.

Content
Content
s

Create Related Tables continued

Along with deciding on the necessary tables


for a database, you also need to determine
the relationship between tables.
The ability to relate, or join, tables is what
makes Access a relational database system.

databa
se
diagra
m

ParadigmPublishing,Inc.

Content
Content
s

Create Related Tables continued

When a new record is added to a table,


Access checks to ensure that there is no
existing record with the same data in the
primary key. If there is, Access displays an
error message indicating there are
duplicate values and will not allow the new
record to be saved.
When adding a new record to a table, the
primary key field cannot be left blank.
Access expects a value in each record in
the table and this is referred to as entity
integrity.

ParadigmPublishing,Inc.

Content
Content
s

Create Related Tables continued


To display a table in Design
view:
1. Open table.
2. Click View button.

View
button

ParadigmPublishing,Inc.

Content
Content
s

Create Related Tables continued

To add or remove a primary key from a


field:
1. Click desired field in Field Name column.
2. Click TABLE TOOLS DESIGN tab.
3. Click Primary Key button.

Primary
Key
button

ParadigmPublishing,Inc.

Content
Content
s

Create Related Tables continued

Typically, a primary key field in one table


becomes the foreign key field in a related
table.

primary key and


associated
foreign key

ParadigmPublishing,Inc.

10

Content
Content
s

Create Related Tables continued

In Access, one table can be related to


another, which is generally referred to as
performing a join.
One type of relationship is a one-to-many
relationship, which means that one record
in one table will match zero, one, or many
records in another table.

ParadigmPublishing,Inc.

11

Content
Content
s

Create Related Tables continued

To create a one-to-many relationship:


1. Open desired database.
2. Click DATABASE TOOLS tab.
3. Click Relationships button.
Relationships
button

continues on next slide


ParadigmPublishing,Inc.

12

Content
Content
s

Create Related Tables continued


4. At Show Table
dialog box, click
first table name.
5. Click Add button.
6. Repeat Steps 4 and
5 until all desired
table names have
been added.
7. Click Close button.

Show
Table
dialog
box

continues on next slide

ParadigmPublishing,Inc.

13

Content
Content
s

Create Related Tables continued

8. At Relationships window, drag common


field to related table.

Relationships
window

continues on next slide


ParadigmPublishing,Inc.

14

Content
Content
s

Create Related Tables continued


9. At Edit Relationships
dialog box, check to
make sure correct
field name displays
and relationship type
displays as One-ToMany.
10.Specify relationship
options.
11.Click Create button.

ParadigmPublishing,Inc.

15

Edit
Relationships
dialog box

Content
Content
s

Create Related Tables continued

Choose Enforce Referential Integrity at the


Edit Relationships dialog box to ensure that
the relationships between records in related
tables are valid.
Referential integrity can be set if the field
from the primary table is a primary key and
the related fields have the same data type.

ParadigmPublishing,Inc.

16

Content
Content
s

Create Related Tables continued

In the image below, the Suppliers table


displays with a black line attached along
with the number 1 (signifying the one side
of the relationship). The black line is
connected to the Products table along with
the infinity symbol (signifying the many
side of the relationship).

join
line
ParadigmPublishing,Inc.

17

Content
Content
s

Create Related Tables continued

To print relationships:
1. Click DATABASE TOOLS tab.
2. Click Relationships button.
3. Click Relationship Report button.

continues on next slide

Relationshi
p Report
button

ParadigmPublishing,Inc.

18

Content
Content
s

Create Related Tables continued


4. Click Print button.
5. Click OK.
6. Click Close button.
Print
button

ParadigmPublishing,Inc.

19

Content
Content
s

Create Related Tables continued

To display the Show Table dialog box:


1. Click Show Table button.

Show Table
button

ParadigmPublishing,Inc.

20

Content
Content
s

Create Related Tables continued

To edit a
relationship:
1. Click DATABASE
TOOLS tab.
2. Click Relationships
button.
3. Click Edit
Relationships
button.
4. Make desired
changes at Edit
Relationships dialog
box.
5. Click OK.
ParadigmPublishing,Inc.
21

Edit
Relationships
dialog box

Content
Content
s

Create Related Tables continued


To
delete a relationship:
1. Click DATABASE TOOLS tab.
2. Click Relationships button.
3. Right-click black line connecting related
tables.
4. Click Delete.
5. Click Yes.
Delete
option

ParadigmPublishing,Inc.

22

Content
Content
s

CHECKPOINT 1
1) Access is this type of
database management
system.
a. flat file
b. relational
c. directional
d. organizational Answer

3) The infinity symbol signifies


this side of the relationship.
a. many
b. one
c. two
d. three

2) Typically, a primary key


field in one table becomes
this key field in a related
table.
a. figure
b. international
c. foreign
Answer
d. secondary
Next

4) To edit a relationship, click


the Relationships button on
this tab.
a. HOME
b. DATABASE DESIGN
c. DATABASE TOOLS
d. CREATE
Answer

Next
Question

Answer
Next
Question

Next Slide

Next
Question

ParadigmPublishing,Inc.

23

Content
Content
s

Create a One-to-One
Relationship

You can create a one-to-one relationship


between tables in which each record in the
first table matches only one record in the
second table and one record in the second
table matches only one record in the first
table.

one-toone
relations
ParadigmPublishing,Inc.
hip

24

Content
Content
s

Create a One-to-One Relationship - continued

To create a one-to-one relationship:


1. Open database.
2. Click DATABASE TOOLS tab.
3. Click Relationships button.
Relationships
button

continues on next slide


ParadigmPublishing,Inc.

25

Content
Content
s

Create a One-to-One Relationship - continued

4. At Show Table
dialog box, click
first table name.
5. Click Add button.
6. Repeat Steps 4
and 5 until all
desired table
names have been
added.
7. Click Close button.

continues on next slide

ParadigmPublishing,Inc.

Show
Table
dialog
box
26

Content
Content
s

Create a One-to-One

Relationshipcontinued
8. At the Relationships window, drag the
common field to the related table.
continues on next slide

Relationshi
ps window

ParadigmPublishing,Inc.

27

Content
Content
s

Create a One-to-One Relationship - continued

9. At Edit Relationships
dialog box, make
sure correct field
name displays and
relationship type
displays as One-ToOne.
10.Specify relationship
options.
11.Click Create button.

ParadigmPublishing,Inc.

28

Edit
Relationships
dialog box

Content
Content
s

Display Related Records in a Subdatasheet

When a relationship is established between


tables, you can view and edit records in
related tables with a subdatasheet.

subdatashe
et
ParadigmPublishing,Inc.

29

Content
Content
s

Display Related Records in a Subdatasheet continued

To display a
subdatasheet:
1. Open table.
2. Click expand
indicator at left side
of desired record.
3. Click desired table
at Insert
Subdatasheet dialog
box.
4. Click OK.

ParadigmPublishing,Inc.

30

Insert
Subdatasheet
dialog box

Content
Content
s

Display Related Records in a Subdatasheet continued

To display
subdatasheets for
all records:
1. Click More button.
2. Point to
Subdatasheet.
3. Click Expand All.

Expand All
option

ParadigmPublishing,Inc.

31

Content
Content
s

Display Related Records in a Subdatasheet continued

To remove a
subdatasheet:
1. Click More button.
2. Point to
Subdatasheet.
3. Click Remove.

Remove
option

ParadigmPublishing,Inc.

32

Content
Content
s

CHECKPOINT 2
1) This type of relationship is
used when you want to
break a large table into two
smaller tables.
a. many-to-many
b. many-to-one
Answer
c. one-to-many
Next
d. one-to-one
Question
2) Add tables to the
Relationships window at
this dialog box.
a. Show Table
b. Show Relationships
c. Edit Relationships
d. Edit Table
Answer
Next
Question
ParadigmPublishing,Inc.

3) To display a subdatasheet,
click this preceding the
record.
a. view indicator
b. expand indicator
c. collapse indicator
Answer
d. remove indicator

Next
Question

4) To display all
subdatasheets, start by
clicking this button on the
HOME tab.
a. View
b. Expand
c. Display
Answer
d. More
Next Slide
Next Slide

33

Content
Content
s

Creating Relationships
between Tables
Summary of Presentation Concepts
Define a primary key in a table
Create a one-to-many relationship
Specify referential integrity
Print, edit, and delete relationships
Create a one-to-one relationship
View and edit a subdatasheet

ParadigmPublishing,Inc.

34

Content
Content
s

You might also like