24
Microsoft Office Access 2007: Intermediate Course 01 – Relational Databases

Microsoft Office Access 2007: Intermediate Course 01 ... · Microsoft Office Access 2007: Intermediate ... C. Access Key D. Primary Key 3. True or False: In a related table, only

Embed Size (px)

Citation preview

Microsoft Office Access 2007: Intermediate

Course 01 – Relational Databases

Slide 1

Cours

e I

LT

Relational Databases

Course objectives

Normalize tables

Set relationships between tables

Implement referential integrity

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 2

Cours

e I

LT

Topic A

Topic A: Database Normalization

Topic B: Relating Tables

Topic C: Implementing Referential

Integrity

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 3

Cours

e I

LT

Normalization

Normalized tables are

Low maintenance because they don’t

have duplicate data

Flexible, enabling querying with ease

Adaptable, absorbing business

changes without requiring extensive

design modification

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 4

Cours

e I

LT

Steps to Normalize – Rule 1

Take small bites and no repeating

Will you need to sort, group by, or print

a subset of the information in the field?

If so, break it up

Do you see the same kind of

information in more than one field?

Will you need to add more fields in the

future? If so, move this information to

another table in one tall field

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 5

Cours

e I

LT

Steps to Normalize – Rule 2

Stay on topic – Each non-key field must relate to the entire multiple-field primary key

Does data in the multiple-field primary key indicate the value of the non-key field? If so, move that non-key field to another table

Does the value in the non-key field correspond directly to the values in the multiple-field primary key? If not, move that non-key field to another table

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 6

Cours

e I

LT

Steps to Normalize – Rule 3

Stay on topic – Each non-key field must

relate to the entire single-field primary

key

Is data in this non-key field a fact

about the primary key? If not, move

that non-key field to another table

Could we have more than one non-key

field for a single primary key? If so,

move the non-key field to another

table

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 7

Cours

e I

LT

Topic B

Topic A: Database Normalization

Topic B: Relating Tables

Topic C: Implementing Referential

Integrity

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 8

Cours

e I

LT

Establishing Relationships

1. Click the Relationships button

2. Click Show Table

3. Select the desired table and click Add

4. Click Close

5. In the Relationships window, drag the desired field from the first table to the desired field in the second table

6. Click Join Type

7. Select the desired properties option

8. Check Enforce Referential Integrity and click Create

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 9

Cours

e I

LT

Relationships Window

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 10

Cours

e I

LT

One-to-Many Relationship

Two tables have a one-to-many

relationship when one record in the

primary table relates to several

records in the related table

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 11

Cours

e I

LT

Junction Tables

Used to create a many-to-many

relationship

Act as a link between two tables

Contain primary key fields of both

tables to be related

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 12

Cours

e I

LT

Many-to-Many with Junction

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 13

Cours

e I

LT

Printing Table Relationships

1. In the Design tab, click Relationship

Report. The report opens in Print Preview

mode

2. Right-click the report tab and choose

Design view

3. Make any necessary changes to the

header, detail, or footer of the report, and

save your changes

4. Right-click the report tab and choose Print

Preview. Verify the appearance of the

report

5. On the Print Preview tab, click Print

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 14

Cours

e I

LT

Topic C

Topic A: Database Normalization

Topic B: Relating Tables

Topic C: Implementing Referential

Integrity

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 15

Cours

e I

LT

Referential Integrity

The primary table must have a primary

key

The related fields should be of same

data type

The tables must belong to the same

database

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 16

Cours

e I

LT

Orphan Records

Records in a table that have no related

records in the primary table

Result from deleting records in the

primary table without deleting the

related records in the related table

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 17

Cours

e I

LT

Cascading Deletes

1. Open the Relationships window

2. Double-click the line between tables

3. Check Enforce Referential Integrity

4. Check Cascade Delete Related

Records

5. Click OK

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 18

Cours

e I

LT

Test Cascading Deletes

1. Open the desired table

2. Navigate to the record to be deleted

3. Press Delete

4. Click Yes to delete the record

5. Update and close the table

6. Open a related table to confirm that

all related records have been deleted

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 19

Cours

e I

LT

Cascading Updates

Ensure that any changes made to the

primary key in the primary table are

reflected in the related tables

Can be set by checking Cascade

Update Related Records in the Edit

Relationships dialog box

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Slide 20

Cours

e I

LT

Course Summary

Normalized tables to reduce data

redundancy

Set relationships between tables

Implemented referential integrity

between related tables

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Review Questions:

1. What is the first rule of data normalization?

A. Each non-key field must relate to the whole multiple-field primary key

B. Each non-key field must relate to the single-field primary key

C. Fields should contain the smallest meaningful value, and there should be no repeating

groups of fields

D. None of the above

2. Table relationships are based on matching fields. When the matching field is the in a

table, that table is known as the related table.

A. Foreign Key

B. Main table

C. Access Key

D. Primary Key

3. True or False: In a related table, only one field can be linked to a field in another table.

A. True

B. False

4. True or False: To establish a table relationship, the first step is to go to the Database Tools tab and

click Relationships.

A. True

B. False

5. What is the purpose of creating a junction table?

A. Create a one-to-one relationship

B. Create a one-to-many relationship

C. Create a many-to-many relationship

D. All of the above

6. What is/are the requirement(s) that must be satisfied before referential integrity can be

implemented?

A. The primary table has a primary key

B. The related fields are the same data type

C. The tables belong to the same database

D. All of the above

Answer Key:

1. C

Fields should contain the smallest meaningful value, and there should be no repeating groups of

fields.

2. A

Table relationships are based on matching fields. When the matching field is the foreign key in a

table, that table is known as the related table.

3. B

False. In a related table, one or more fields can be linked to fields in another table. The link ensures

that you can enter only those values that have corresponding entries in the other table. A relational

database is in the form of related tables.

4. A

True. To establish a table relationship, the first step is to go to the Database Tools tab and click

Relationships.

5. C

The purpose of a junction table is to create a many-to-many relationship between Access tables.

6. D

All three are requirements that must be satisfied before referential integrity can be implemented.