Download Extended Learning Module C

Document related concepts

Microsoft Access wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Relational algebra wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Ingres (database) wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Versant Object Database wikipedia , lookup

Clusterpoint wikipedia , lookup

ContactPoint wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

Transcript
Extended Learning Module J
IMPLEMENTING A DATABASE IN MICROSOFT
ACCESS
McGraw-Hill
© 2008 The McGraw-Hill Companies, Inc. All rights reserved.
STUDENT LEARNING OUTCOMES
1.
2.
3.
Identify the steps necessary to implement the
structure of a relational database using the data
definition language provided by Microsoft Access.
Demonstrate how to use the data manipulation
subsystem in Access to enter and change
information in a database and how to query that
information.
Explain the use of the application generation
subsystem in Access to create reports and data
entry screens.
J-2
MODULE ORGANIZATION
1.
Solomon Enterprises Database

2.
3.
Defining Relationships within the Solomon
Enterprises Database
Entering Information into the Solomon Database

4.
Learning Outcome #1
Learning Outcome #2
Creating a Simple Query Using One Relation
J-3
MODULE ORGANIZATION
5.
6.
Creating an Advanced Query Using More than
One Relation
Generating a Simple Report

7.
8.
Learning Outcome #3
Generating a Report with Grouping, Sorting, and
Totals
Creating a Data Input Form
J-4
SOLOMON DATABASE

The steps to creating a database are
1.
2.
3.
4.
Define entity classes and primary keys
Define relationships among the entity classes
Define fields for each relation (file)
Use a data definition language to create the
database, which is the focus of this Module
J-5
SOLOMON DATABASE
 In
Figure J.1 (p. 432) 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
J-6
SOLOMON DATABASE
J-7
SOLOMON DATABASE
J-8
SOLOMON DATABASE
J-9
Creating Solomon’s Database


Data dictionary - contains the logical structure for
the information
To create the Solomon Enterprise database:
1.
2.
3.
4.
Start Microsoft Access
Click on Blank Database in the upper left corner of
the screen
Enter Solomon Enterprises.mdb as the database
name
Click on Create
J-10
Creating Solomon’s Database
Enter a database
name and click
on Create
Click on Blank
Database
J-11
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

J-12
Creating Solomon’s Database
This is Design View –
our recommendation
for creating the tables
in a database
To switch to
Design View, click
on View and then
Design View
J-13
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
J-14
Creating the Raw Material Relation
Primary key identifier and
the Primary key button
Integrity constraints for
Raw Material ID
J-15
Creating the Concrete Type Relation
J-16
Creating the Bill of Material Relation
 We
created (in Extended Learning Module C) the
Bill of Material relation to eliminate the many-tomany relationship between the Concrete Type and
Raw Material relations
J-17
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
J-18
Creating the Bill of Material Relation
Composite
primary key
J-19
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)
J-20
Primary and Foreign Key Logical Ties
J-21
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

J-22
Defining Relationships between
Relations
Select tables
and click on Add
Relationship
palette
J-23
Defining Relationships between
Relations
J-24
ENTERING INFORMATION INTO
SOLOMON’S DATABASE
 To
enter information, you simply double-click on the
appropriate relation name
Supplier relation
structure
J-25
Entering Information
J-26
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
J-27
Enforcing Referential Integrity
J-28
Change the Structure of a Relation
J-29
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

J-30
Creating a Simple Query Using the
Raw Material Relation
Second, select the table,
click on Add, and then
close the box.
First, click on Create and
then Query Design
J-31
Creating a Simple Query Using the
Raw Material Relation
The result of the
query
Drag and drop the appropriate
field names and then click on the
exclamation point (Run).
J-32
Creating a Simple Query with a
Condition
Set the condition
here
J-33
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

J-34
Steps to Create an Advanced Query
1.
2.
Click on Create in the menu area and then Query
Design
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
J-35
Steps to Create an Advanced Query
3.
4.
Drag and drop the fields that you want from the
appropriate relation into the QBE grid in the order
that you want
Click on the exclamation point (Run) in the button
bar to see the results of the query
J-36
Steps to Create an Advanced Query
J-37
Steps to Create an Advanced Query
J-38
Steps to Create an Advanced Query
J-39
GENERATING A SIMPLE REPORT
1.
2.
3.
Click on Create in the menu area and then the
Report Wizard button
Choose tables and/or queries: Lets you choose
which table/query you want
Choose fields: Lets you choose the fields you want
J-40
Grouping, Sorting, Layout of Report
4.
5.
6.
Grouping: Lets you specify grouping of information
(we chose the default)
Sorting: Allows you to specify sorting (we chose
the default)
Layout and orientation: Allows you to select layout
and page orientation (we chose the default)
J-41
Style and Header of Report
7.
8.
9.
Style: Allows you to choose from among
predefined report styles (we chose the default)
Report header: Allows us to enter a title for the
report.
The Report: Shows all customers and phone
numbers.
J-42
Choose Table/Query and Fields
2. Choose tables and/or queries
1. Start to create a report
J-43
Choose Table/Query and Fields
4. Grouping
3. Choose fields
J-44
Grouping, Sorting, Layout, Style, and
Title
6. Layout and orientation
5. Sorting
J-45
Grouping, Sorting, Layout, Style, and
Title
8. Report Header
7. Style
J-46
Grouping, Sorting, Layout, Style, and
Title
J-47
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
J-48
Steps for Creating a Report with
Grouping, Sorting, and Totals
1.
2.
3.
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 (>>)
J-49
Specify Table/Query Fields
J-50
Grouping and Sorting Information
4.
5.
6.
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
J-51
Steps for Grouping Information
J-52
Steps for Sorting Information
J-53
Totaling Information in a Report
7.
Totaling: The sorting screen also has a Summary
Options button

Within Summary Options you can choose what
type of summary you want
J-54
Totaling Information in a Report
J-55
Formatting the Report
8.
9.
10.
Overall structure of report: Allows you to choose
the layout and orientation
Style of report: Allows you to choose a style
Report heading: Allows you to enter the title that
will appear on the report, then click on Finish
J-56
Formatting the Report
J-57
The Report
11.
The Report: Shows the information from the wizard
steps
J-58
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

J-59
Refining the Report
Click on Design
View to see the
report in design
format
J-60
Adjusting the Page Header
J-61
Adjusting the Concrete Type Header
J-62
Adjusting the Detail Section
J-63
Adjusting the Concrete Type Footer
J-64
The Completed Report
J-65
CREATING A DATA INPUT FORM
1.
2.
Select the Order table
Click on Create and then Form
J-66
Choose Table/Query
J-67
Final Input Form
J-68