23
Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

Embed Size (px)

Citation preview

Page 1: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

Working with Multiple Tables in Microsoft Access

The Access Workbench: Section Two

DAVID M. KROENKE and DAVID J. AUER

DATABASE CONCEPTS, 3rd Edition

Page 2: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-2

Section Objectives

Learn how to use Microsoft Access to: Illustrate modification problems Create relationships between tables Create multiple-table forms Create multiple-table reports

Page 3: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-3

Illustrating Modification Problems

• When a table contains data from multiple themes, it is subject to modification problems

• This topic was discussed in detail in Chapter 1

• We will use an Access database to illustrate a modification problem

• The data is in a provided database named WMCRM-Combined-Data.mdb

Page 4: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-4

CONTACT Data

CustomerID Date Type Remarks

1 7/7/2005 Phone General interest in a Gaea.

1 7/7/2005 Email Sent general information.

1 7/12/2005 Phone Set up an appointment.

1 7/14/2005 Meeting Bought a HiStandard.

3 7/19/2005 Phone Interested in a SUHi, set up an appointment.

1 7/21/2005 Email Sent a standard follow-up message.

4 7/27/2005 Phone Interested in a HiStandard, set up an appointment.

3 7/27/2005 Meeting Bought a SUHi.

4 8/2/2005 Meeting Talked up to a HiLuxury. Customer bought one.

3 8/3/2005 Email Sent a standard follow-up message.

4 8/10/2005 Email Sent a standard follow-up message.

5 8/15/2005 Phone General interest in a Gaea.

temp
Au: Update the year in the Date column to 2006? or even later (e.g., 2007)? Make this a global change, as appropriate?
David J. Auer
Updating these dates will affect countless other figures in the rest of the book. While in principle I agree with the idea, in practice I think it would require too much work at this point. While older dates (2002, 2003, etc.) should be updated, I suggest we live with 2005 in this case.
Page 5: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-5

Security Warning

• Each time you open an existing database, the Security Warning dialog box will be displayed–as long as you are familiar with the database file, Click the Open button

Page 6: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-6

Illustrating Modification Problems:

The CUSTOMER_CONTACT Table

temp
Au: Note how copy is cut off in the "Email" and "Remark" columns. OK?
David J. Auer
YES - This is a lage, wide table, and the Figure needs to show general content, not all details.
Page 7: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-7

Illustrating Modification Problems:The Customer-Contact Data Input Form

All fields from the CUSTOMER_CONTACT table appear on the form

Form browsing buttons

Page 8: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-8

Illustrating Modification Problems:The Wallingford Motors Customer Contact Report

All contact data for each customer is grouped together and sorted by date

Page 9: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-9

Illustrating Modification Problems:

Form with the Updated Email Address

The Email address has been updated

Next record button

Page 10: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-10

Illustrating Modification Problems:Updated Wallingford Motors Customer Contact Report

A modification problem has occurred. Not all records were updated with the new email address, and the database records are now inconsistent.

Page 11: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-11

Working with Multiple Tables:WMCRM Database Schema

CUSTOMER (CustomerID, LastName, FirstName, Address, City, State, ZIP,Phone, Fax, Email)

CONTACT (ContactID, CustomerID, Data, Type, Remarks)

CustomerID in CONTACT must exist in CustomerID in CUSTOMER

Page 12: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-12

Working with Multiple Tables: CONTACT Table Column Characteristics

Column Name Type Key Required Remarks

ContactID AutoNumber Primary Key Yes Surrogate Key

CustomerID Number Foreign Key Yes Long Integer

Date Date/Time No Yes Short Date

Type Text (10) No Yes Allowed values are Phone, Fax, Email and Meeting

Remarks Memo No No

CONTACT

Page 13: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-13

Working with Multiple Tables:Setting the Date Format

Select the Short Date date format from the drop-down list

temp
Au: Note the repeat of the word "Date" in the callout box: "Select the Short Date date..." Delete the second "date"?
David J. Auer
NO. We are dealing with date formats, and Short Date is a date format. The construction is somewhat awkward, but correct.
Page 14: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-14

Working with Multiple Tables:

Opening the Relationships Window

Click Tools, then click Relationships…

Page 15: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-15

Working with Multiple Tables:Adding Tables to the Relationships Window

Select a table name, then click the Add button to add the table to the Relationships window

Page 16: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-16

Working with Multiple Tables:Creating a Relationship

• To create a relationship between two tables:– In the Relationships window, drag a

primary key column and drop it on top of the corresponding foreign key column

Page 17: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-17

Working with Multiple Tables:The Table Objects in the Relationships Window

The table objects have been enlarged and rearranged into the arrangement shown here

Click, drag and drop the CUSTOMER CustomerID field onto the CONTACT CustomerID field

Page 18: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-18

Working with Multiple Tables:The Edit Relationships Dialog Box

Click the Enforce Referential Integrity check box, and then click the Create button to create the relationship

Page 19: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-19

Working with Multiple Tables:The Completed Relationship

The new relationship now appears in the Relationships window diagram—note that the line connects the related fields

Page 20: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-20

Working with Multiple Tables:Data in the CONTACT Table

Page 21: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-21

Working with Multiple Tables:The Completed Form for CUSTOMER and CONTACT Data

Buttons for scrolling through the CONTACT records for this customer

Buttons for scrolling through the CUSTOMER records

Page 22: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3rd Edition)© 2008 Pearson Prentice Hall AW-2-22

Working with Multiple Tables:The Wallingford Motors Customer Contacts Report

Data for each customer

List of contact data for each customer

temp
Au: Note that the copy is cut off in the final ("Remarks") column. OK?
David J. Auer
YES, this is a screen shot of what will appear in ACCESS when the report is generated.
Page 23: Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

Working with Multiple Tables in Microsoft Access

End of Presentation on The Access Workbench: Section Two

DAVID M. KROENKE and DAVID J. AUER

DATABASE CONCEPTS, 3rd Edition