65
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2010 Version) Implementing a Database with Microsoft Access

Extended Learning Module J (Office 2010 Version)

  • Upload
    amora

  • View
    42

  • Download
    3

Embed Size (px)

DESCRIPTION

Extended Learning Module J (Office 2010 Version). Implementing a Database with Microsoft Access. SOLOMON DATABASE. The steps to creating a database are Define entity classes and primary keys Define relationships among the entity classes Define fields for each relation (file) - PowerPoint PPT Presentation

Citation preview

Page 1: Extended Learning Module J (Office 2010 Version)

McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved.

Extended Learning Module

J (Office 2010 Version)

Implementing a Database with Microsoft Access

Page 2: Extended Learning Module J (Office 2010 Version)

Mod J-2

SOLOMON DATABASE

The steps to creating a database are

1. Define entity classes and primary keys

2. Define relationships among the entity classes

3. Define fields for each relation (file)4. Use a data definition language to

create the database, which is the focus of this Module

Page 3: Extended Learning Module J (Office 2010 Version)

Mod J-3

SOLOMON DATABASE

In Figure J.1 (p. 474) on the following 3 slides, we’ve recreated the correct database structure from Extended Learning Module C

Revisit Module C if you need a refresher

Page 4: Extended Learning Module J (Office 2010 Version)

Mod J-4

SOLOMON DATABASE

Page 5: Extended Learning Module J (Office 2010 Version)

Mod J-5

SOLOMON DATABASE

Page 6: Extended Learning Module J (Office 2010 Version)

Mod J-6

SOLOMON DATABASE

Page 7: Extended Learning Module J (Office 2010 Version)

Mod J-7

Creating Solomon’s Database

Data dictionary - contains the logical structure for the information

To create the Solomon Enterprise database:

1. Start Microsoft Access2. Click on Blank Database in the upper

left corner of the screen3. Enter Solomon Enterprises.accdb as

the database name4. Click on Create

Page 8: Extended Learning Module J (Office 2010 Version)

Mod J-8

Creating Solomon’s Database

1. Create a new database by clicking on Blank Database 2. Enter SolomonEnterprises.accdb

Page 9: Extended Learning Module J (Office 2010 Version)

Mod J-9

Creating Solomon’s Database

Our recommendation: Create a relation (table) in Design view: Must switch from Datasheet View

to Design View Click on View in the upper left

corner and then Design View Enter a table name Use the Design View to enter the

specifications for the table

Page 10: Extended Learning Module J (Office 2010 Version)

Mod J-10

Creating Solomon’s Database

To switch to Design View, To switch to Design View, click on click on ViewView and then and then

Design ViewDesign View

This is This is Design View Design View – our – our recommendation for creating recommendation for creating

the tables in a databasethe tables in a database

Page 11: Extended Learning Module J (Office 2010 Version)

Mod J-11

Creating the Raw Material Relation

Enter the four fields of the Raw Material relation Raw Material ID Raw Material Name QOH Supplier ID

Click on the Raw Material ID row and then the key button to designate Raw Material ID as the primary key

Page 12: Extended Learning Module J (Office 2010 Version)

Mod J-12

Creating the Raw Material Relation

Primary key identifier and Primary key identifier and the the Primary key Primary key buttonbutton

Integrity constraints for Integrity constraints for Raw Material IDRaw Material ID

Page 13: Extended Learning Module J (Office 2010 Version)

Mod J-13

Creating the Concrete Type Relation

The fields for The fields for Concrete TypeConcrete Type

Primary KeyPrimary Key

Integrity ConstraintsIntegrity Constraints

Page 14: Extended Learning Module J (Office 2010 Version)

Mod J-14

Creating the Bill of Material Relation

We created (in Extended Learning Module C) the Bill of Material relation to eliminate the many-to-many relationship between the Concrete Type and Raw Material relations

Page 15: Extended Learning Module J (Office 2010 Version)

Mod J-15

Creating the Bill of Material Relation

The Bill of Material relation has a primary key composed of two fields (composite primary key): Concrete Type Raw Material ID

Composite primary key - consists of the primary key fields from the two intersecting relations

Page 16: Extended Learning Module J (Office 2010 Version)

Mod J-16

Creating the Bill of Material Relation

Composite Composite primary keyprimary key

Page 17: Extended Learning Module J (Office 2010 Version)

Mod J-17

DEFINING RELATIONSHIPS WITHIN SOLOMON’S

DATABASE The final structural task is to

define how all the relations relate to each other

That is, link primary and foreign keys

Foreign key - a primary key of one file (relation) that appears in another file (relation)

Page 18: Extended Learning Module J (Office 2010 Version)

Mod J-18

Primary and Foreign Key Logical Ties

Page 19: Extended Learning Module J (Office 2010 Version)

Mod J-19

Defining Relationships between Relations

To create relationships Click on Database Tools in the

menu area and then click on the Relationships button

Make each relation appear on the palette by highlighting each relation name and clicking on Add

Then click on the Close button

Page 20: Extended Learning Module J (Office 2010 Version)

Mod J-20

Defining Relationships between Relations

Relationship Relationship palettepalette

Select tables and Select tables and click on click on AddAdd

Page 21: Extended Learning Module J (Office 2010 Version)

Mod J-21

Defining Relationships between Relations

Page 22: Extended Learning Module J (Office 2010 Version)

Mod J-22

ENTERING INFORMATION INTO SOLOMON’S

DATABASE

Double-click on any table to Double-click on any table to begin entering informationbegin entering information

Page 23: Extended Learning Module J (Office 2010 Version)

Mod J-23

Entering Information

We double-clicked on the We double-clicked on the SupplierSupplier table and table and can now begin entering informationcan now begin entering information

We have completed entering We have completed entering all supplier informationall supplier information

Page 24: Extended Learning Module J (Office 2010 Version)

Mod J-24

Referential Integrity

Referential integrity ensures consistency. For example, that you don’t put a non-existent Supplier ID into the Raw Material relation

The relationships we set up for referential integrity guard against bad information

Integrity constraints – rules that help ensure the quality of the information

Page 25: Extended Learning Module J (Office 2010 Version)

Mod J-25

Enforcing Referential Integrity

Because we entered a non-Because we entered a non-existent existent Supplier ID Supplier ID (445) that (445) that doesn’t exist, Access will not doesn’t exist, Access will not

allow us to continueallow us to continue

If you try to close the If you try to close the window, Access will window, Access will

allow you to change the allow you to change the information or save the information or save the

good information good information without the badwithout the bad

Page 26: Extended Learning Module J (Office 2010 Version)

Mod J-26

Change the Structure of a Relation

You can change the structure of a relation by You can change the structure of a relation by clicking on clicking on View View and then and then DesignDesign ViewView

In Design View, you can In Design View, you can change the structure of a change the structure of a

tabletable

Page 27: Extended Learning Module J (Office 2010 Version)

Mod J-27

CREATING A SIMPLE QUERY USING ONE

RELATION Query-by-example (QBE) tool

- helps you graphically design the answer to a question

Suppose we wanted to see a list of raw materials that shows Raw Material Name Supplier ID

Page 28: Extended Learning Module J (Office 2010 Version)

Mod J-28

Creating a Simple Query Using the Raw Material

RelationFirst, click on First, click on CreateCreate and and

then then Query DesignQuery Design

Second, select the table, Second, select the table, click on click on AddAdd, and then , and then

close the box.close the box.

Page 29: Extended Learning Module J (Office 2010 Version)

Mod J-29

Creating a Simple Query Using the Raw Material

Relation

The result of the queryThe result of the query

Drag and drop the appropriate Drag and drop the appropriate field names and then click on the field names and then click on the

exclamation point (exclamation point (RunRun).).

Page 30: Extended Learning Module J (Office 2010 Version)

Mod J-30

Creating a Simple Query with a Condition

Set the condition hereSet the condition here

Page 31: Extended Learning Module J (Office 2010 Version)

Mod J-31

CREATING AN ADVANCED QUERY USING MORE THAN ONE RELATION

Suppose we want a query that shows All order numbers Date of orders Where the goods were delivered The contact person The truck involved in each delivery The truck driver in each delivery

Page 32: Extended Learning Module J (Office 2010 Version)

Mod J-32

Steps to Create an Advanced Query

1. Click on Create in the menu area and then Query Design

2. In the Show Table dialog box Select and Add the relation names Close the Show Table dialog box Tables linked appear are joined by

lines with 1 beside the table with the primary key The infinity sign by the table with the

foreign key

Page 33: Extended Learning Module J (Office 2010 Version)

Mod J-33

Steps to Create an Advanced Query

3. Drag and drop the fields that you want from the appropriate relation into the QBE grid in the order that you want

4. Click on the exclamation point (Run) in the button bar to see the results of the query

Page 34: Extended Learning Module J (Office 2010 Version)

Mod J-34

Steps to Create an Advanced Query

From the From the Show Table Show Table box, box, select the appropriate tables – select the appropriate tables – Customer, Order, Employee Customer, Order, Employee

andand Truck Truck

Page 35: Extended Learning Module J (Office 2010 Version)

Mod J-35

Steps to Create an Advanced Query

Drag and drop the appropriate fieldsDrag and drop the appropriate fields

Page 36: Extended Learning Module J (Office 2010 Version)

Mod J-36

Steps to Create an Advanced Query

The completed queryThe completed query

Page 37: Extended Learning Module J (Office 2010 Version)

Mod J-37

GENERATING A SIMPLE REPORT

1. Click on Create in the menu area and then the Report Wizard button

2. Choose tables and/or queries: Lets you choose which table/query you want

3. Choose fields: Lets you choose the fields you want

Page 38: Extended Learning Module J (Office 2010 Version)

Mod J-38

Grouping, Sorting, Layout of Report

4. Grouping: Lets you specify grouping of information (we chose the default)

5. Sorting: Allows you to specify sorting (we chose the default)

6. Layout and orientation: Allows you to select layout and page orientation (we chose the default)

Page 39: Extended Learning Module J (Office 2010 Version)

Mod J-39

Style and Header of Report

7. Report header: Allows us to enter a title for the report.

8. The Report: Shows all customers and phone numbers.

Page 40: Extended Learning Module J (Office 2010 Version)

Mod J-40

Choose Table/Query and Fields

Click on Click on CreateCreate and then and then Report WizardReport Wizard

Choose tables and/or queriesChoose tables and/or queries

Page 41: Extended Learning Module J (Office 2010 Version)

Mod J-41

Choose Table/Query and Fields

Select fields by clicking on Select fields by clicking on each and clicking on the each and clicking on the >>

Then click on Then click on NextNext

4. Grouping4. Grouping

We don’t need grouping so We don’t need grouping so click on click on NextNext..

Page 42: Extended Learning Module J (Office 2010 Version)

Mod J-42

Sorting and Layout

We don’t need to sort so click We don’t need to sort so click on on NextNext..

Select a Select a LayoutLayout and and OrientationOrientation

Page 43: Extended Learning Module J (Office 2010 Version)

Mod J-43

Style and Title

Choose a Choose a Style Style then then click on click on NextNext..

Enter a report headerEnter a report header and click on and click on FinishFinish

The wizard generated The wizard generated completed reportcompleted report

Page 44: Extended Learning Module J (Office 2010 Version)

Mod J-44

Changing the Look of the Report

Click on Click on Close Print Close Print PreviewPreview

Click on Click on ViewView an an choose choose LayoutLayout View View

Page 45: Extended Learning Module J (Office 2010 Version)

Mod J-45

Changing the Look of a Report

Move the report elements to Move the report elements to change the look of the reportchange the look of the report

Page 46: Extended Learning Module J (Office 2010 Version)

Mod J-46

REPORT WITH GROUPING, SORTING, AND TOTALS

Say we want to create the Supply Chain Management report from Extended Learning Module C

First, create a query Then, put the query into the

report generator

Page 47: Extended Learning Module J (Office 2010 Version)

Mod J-47

Steps for Creating a Report with Grouping,

Sorting, and Totals

Click on Create in the menu area and click on the Report Wizard button

Choose tables/queries: Query: Supply Chain Query

Choose fields: Select all fields by clicking on the double greater-than sign (>>)

Page 48: Extended Learning Module J (Office 2010 Version)

Mod J-48

Specify Table/Query Fields

Select the Select the Supply Chain Supply Chain queryquerySelect all the fields of the Select all the fields of the

Supply Chain Supply Chain queryquery

Page 49: Extended Learning Module J (Office 2010 Version)

Mod J-49

Grouping and Sorting Information

Top-level grouping: Allows you to choose ordering. Since we created a query, Access has defaulted to the first field

Further grouping: Lets you specify groups within the top grouping of Concrete Type, but we don’t want any further grouping

Sorting: Next we have a chance to sort our information

Page 50: Extended Learning Module J (Office 2010 Version)

Mod J-50

Steps for Grouping Information

Group by Group by Concrete Type Concrete Type and and Type DescriptiType Description and on and then click then click NextNext..

Page 51: Extended Learning Module J (Office 2010 Version)

Mod J-51

Sorting Information

Sort on Sort on Raw Material ID Raw Material ID to sort and change to sort and change the order from the order from AscendingAscending to to DescendingDescending. .

Page 52: Extended Learning Module J (Office 2010 Version)

Mod J-52

Totaling Information in a Report

Totaling: The sorting screen also has a Summary Options button Within Summary Options you

can choose what type of summary you want

Page 53: Extended Learning Module J (Office 2010 Version)

Mod J-53

Totaling Information in a Report

Click on Click on Summary Options Summary Options and and check the check the SumSum box for box for UnitUnit..

Page 54: Extended Learning Module J (Office 2010 Version)

Mod J-54

Formatting the Report

Overall structure of report: Allows you to choose the layout and orientation

Report heading: Allows you to enter the title that will appear on the report, then click on Finish

Page 55: Extended Learning Module J (Office 2010 Version)

Mod J-55

Formatting the Report

Choose the desired report layout and orientation.Choose the desired report layout and orientation.

Page 56: Extended Learning Module J (Office 2010 Version)

Mod J-56

The Report The Report: Shows the information

from the wizard steps

Page 57: Extended Learning Module J (Office 2010 Version)

Mod J-57

Refining the Report

Steps to adjust the report to make it aesthetically pleasing Open the report in Design View

with the triangle button Adjust the boxes to the desired size Delete unwanted entries

Page 58: Extended Learning Module J (Office 2010 Version)

Mod J-58

Refining the Report

Click on Click on Design ViewDesign View to to see the report in design see the report in design

formatformat

Click on Click on Close Close Print PreviewPrint Preview..

Page 59: Extended Learning Module J (Office 2010 Version)

Mod J-59

Adjusting the Page Header

Move the divider to make Move the divider to make more heading room and more heading room and change the shape and change the shape and

size of the header boxessize of the header boxes

Click on Click on ViewView and then and then Report View Report View to see the to see the

changeschanges

Page 60: Extended Learning Module J (Office 2010 Version)

Mod J-60

Adjusting the Concrete Type Header

MoveMove Concrete Concrete Type tType to the left o the left and shrink it.and shrink it.

Concrete Type should now Concrete Type should now be lined up under its headerbe lined up under its header

Page 61: Extended Learning Module J (Office 2010 Version)

Mod J-61

Adjusting the Detail Section

Adjust the elements of Adjust the elements of the detail line so that they the detail line so that they line up with their headersline up with their headers

The realigned reportThe realigned report

Page 62: Extended Learning Module J (Office 2010 Version)

Mod J-62

Adjusting the Concrete Type Footer

Delete the Delete the SummarySummary line. line. Change Change SumSum to to Total Total

UnitsUnits, and change its color, and change its color

The completed reportThe completed report

Page 63: Extended Learning Module J (Office 2010 Version)

Mod J-63

CREATING A DATA INPUT FORM

Select the Order table Click on Create and then

Form

Page 64: Extended Learning Module J (Office 2010 Version)

Mod J-64

CREATING A DATA INPUT FORM

1. Select the Order table2. Click on Create and then Form

Page 65: Extended Learning Module J (Office 2010 Version)

Mod J-65

Final Input Form