Contents © Paradigm Publishing, Inc. 1
Mar 31, 2015
Contents© Paradigm Publishing, Inc. 1
Contents© Paradigm Publishing, Inc. 2
Access 2010
Level 1
Unit 1 Creating Tables and Queries
Chapter 2 Creating Relationships between Tables
Contents© Paradigm Publishing, Inc. 3
Creating Relationships between Tables
Create Related Tables CHECKPOINT 1 Create a One-to-One Relationship Display Related Records in a Subdatasheet CHECKPOINT 2
Quick Links to Presentation Contents
Contents© Paradigm Publishing, Inc. 4
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.
Contents© Paradigm Publishing, Inc. 5
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.
Contents© Paradigm Publishing, Inc. 6
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.
database diagram
Contents© Paradigm Publishing, Inc. 7
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.
Contents© Paradigm Publishing, Inc. 8
Create Related Tables…continued
To display a table in Design view:1. Open the desired table.2. Click the View button in
the Views group in the Home tab.
View button
Contents© Paradigm Publishing, Inc. 9
Create Related Tables…continued
To add or remove a primary key from a field:1. Click the desired field
in the Field Name column.
2. Click the Table Tools Design tab.
3. Click the Primary Key button in the Tools group.
Primary Key button
Contents© Paradigm Publishing, Inc. 10
Create Related Tables…continued
primary key and associated foreign key
Typically, a primary key field in one table becomes the foreign key field in a related table.
Contents© Paradigm Publishing, Inc. 11
Create Related Tables…continued
In Access, one table can be related to another, which is generally referred to as performing a join. For example, in Project 1b, you will create a relationship between the Suppliers table and the Products table. The relationship you establish will ensure that a supplier number cannot be entered in the Products table without first being entered in the Suppliers table.
This type of relationship is called a one-to-many relationship, which means that one record in the Suppliers table will match zero, one, or many records in the Products table.
Contents© Paradigm Publishing, Inc. 12
Create Related Tables…continued
To create a one-to-many relationship:1. Open the desired
database.2. Click the Database
Tools tab.3. Click the Relationships
button in the Relationships group.
continues on next slide…
Relationships button
Contents© Paradigm Publishing, Inc. 13
Create Related Tables…continued
4. At the Show Table dialog box, click the first table name.
5. Click the Add button.6. Repeat Steps 4 and 5
until all desired table names have been added.
7. Click the Close button.continues on next slide…
Show Table dialog box
Contents© Paradigm Publishing, Inc. 14
Create Related Tables…continued
8. At the Relationships window, drag the common field to the related table.
continues on next slide…
Relationships window
Contents© Paradigm Publishing, Inc. 15
Create Related Tables…continued
9. At the Edit Relationships dialog box, check to make sure the correct field name displays and the relationship type displays as One-To-Many.
10. Specify the relationship options.
11. Click the Create button.Edit Relationships dialog box
Contents© Paradigm Publishing, Inc. 16
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.
Contents© Paradigm Publishing, Inc. 17
Create Related Tables…continued
join line
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).
Contents© Paradigm Publishing, Inc. 18
Create Related Tables…continued
To print relationships:1. Click the Database Tools tab.2. Click the Relationships button.3. Click the Relationship Report button in the Tools group.continues on next slide…
Relationship Report button
Contents© Paradigm Publishing, Inc. 19
Create Related Tables…continued
4. Click the Print button.5. Click OK.6. Click the Close button.
Print button
Contents© Paradigm Publishing, Inc. 20
Create Related Tables…continued
To display the Show Table dialog box:1. Click the Show Table button in the Relationships group.
Show Table button
Contents© Paradigm Publishing, Inc. 21
Create Related Tables…continued
To edit a relationship:1. Click the Database Tools
tab.2. Click the Relationships
button in the Relationships group.
3. Click the Edit Relationships button in the Tools group.
4. Make the desired changes at the Edit Relationships dialog box.
5. Click OK.
Edit Relationships dialog box
Contents© Paradigm Publishing, Inc. 22
Create Related Tables…continuedTo delete a relationship:1. Click the Database Tools tab.2. Click the Relationships button in the Relationships group.3. Right-click on the black line connecting the related
tables.4. Click the Delete option.5. Click Yes.
Delete option
Contents© Paradigm Publishing, Inc. 23
CHECKPOINT 11) Access is this type of database
management system.a. flat fileb. relationalc. directionald. organizational
3) The infinity symbol signifies this side of the relationship.a. manyb. onec. twod. three
2) Typically, a primary key field in one table becomes this key field in a related table.a. figureb. internationalc. foreignd. secondary
4) To edit a relationship, click the Relationships button in this tab.a. Homeb. Database Designc. Database Toolsd. Create
Next Question
Next Question
Next Question
Next Slide
Answer
Answer
Answer
Answer
Contents© Paradigm Publishing, Inc. 24
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-to-one relationship
Contents© Paradigm Publishing, Inc. 25
Create a One-to-One Relationship…continued
To create a one-to-one relationship:1. Open the desired
database.2. Click the Database
Tools tab.3. Click the Relationships
button in the Relationships group.
continues on next slide…
Relationships button
Contents© Paradigm Publishing, Inc. 26
Create a One-to-One Relationship…continued
4. At the Show Table dialog box, click the first table name.
5. Click the Add button.6. Repeat Steps 4 and 5
until all desired table names have been added.
7. Click the Close button.continues on next slide…
Show Table dialog box
Contents© Paradigm Publishing, Inc. 27
Create a One-to-One Relationship…continued
8. At the Relationships window, drag the common field to the related table.
continues on next slide…
Relationships window
Contents© Paradigm Publishing, Inc. 28
Create a One-to-One Relationship…continued
9. At the Edit Relationships dialog box, check to make sure the correct field name displays and the relationship type displays as One-To-One.
10. Specify the relationship options.
11. Click the Create button.Edit Relationships dialog box
Contents© Paradigm Publishing, Inc. 29
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.
subdatasheet
Contents© Paradigm Publishing, Inc. 30
Display Related Records in a Subdatasheet…continued
To display a subdatasheet:1. Click the expand
indicator at the left side of the desired record.
2. Click the desired table at the Insert Subdatasheet dialog box.
Insert Subdatasheet dialog box
Contents© Paradigm Publishing, Inc. 31
Display Related Records in a Subdatasheet…continued
To display subdatasheets for all records:1. Click the More button in the Records group in the
Home tab.2. Point to Subdatasheet.3. Click the Expand All option.
Expand All option
Contents© Paradigm Publishing, Inc. 32
Display Related Records in a Subdatasheet…continued
To remove a subdatasheet:1. Click the More button in the Records group in the
Home tab.2. Point to Subdatasheet.3. Click the Remove option.
Remove option
Contents© Paradigm Publishing, Inc. 33
CHECKPOINT 21) This type of relationship is used
when you want to break a large table into two smaller tables.a. many-to-manyb. many-to-onec. one-to-manyd. one-to-one
3) To display a subdatasheet, click this preceding the record.a. view indicatorb. expand indicatorc. collapse indicatord. remove indicator
2) Add tables to the Relationships window at this dialog box.a. Show Tableb. Show Relationshipsc. Edit Relationshipsd. Edit Table
4) To display all subdatasheets, start by clicking this button in the Home tab.a. Viewb. Expandc. Displayd. More
Next Question
Next Question
Next Question
Next Slide
Answer
Answer
Answer
Answer
Contents© Paradigm Publishing, Inc. 34
Creating Relationships between Tables
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
Summary of Presentation Concepts