Download Succeeding in Business with Microsoft Excel 2003

Document related concepts

Relational algebra wikipedia , lookup

Clusterpoint wikipedia , lookup

SQL wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Microsoft Access wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Transcript
XP
Analyzing Data For Effective
Decision Making
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
1
XP
Chapter Introduction
•
Filter data in Microsoft Office Access 2003 database
 Retrieve and examine only records you need
•
Sort data
 Rearrange records in specified order
•
Queries
 Provide quick answers to business questions
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
2
XP
Filtering and Sorting Data
•
Filter
 Restricts data in single table to create temporary
subset of records
 See only certain records in table based on specified
criteria
•
Sorting records
 Organizing in particular order or sequence
 Sort records regardless of whether table filtered
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
3
XP
Filtering by Selection
•
Tools
 Filter by Selection
• Select particular field in datasheet
• Display only data that matches contents of field
• Specify only one criterion for filter
 Filter by Form
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
4
Using Filter by Selection to XP
Display a Temporary Subset of
Records
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
5
XP
Filtering by Form
•
•
Specify two or more criteria
Filter for comparative data
 Use comparison operators
•
AND criteria
 Selects records that contain all specified values
•
OR criteria
 Selects records that contain any specified values
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
6
XP
Sorting Data to Increase
Information Content
•
•
Organizes data and increases information value
Access sorts records based on primary key values
 Use sorting to change order
•
To sort
 Select sort field
•
Sort on multiple fields
 Move fields in datasheet view so that they are adjacent
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
7
Sorting Data To Increase
Information Content
•
XP
Primary sort field
 Access sorts records by this field first
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
8
XP
Sorting Types of Data
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
9
XP
Using Queries to Answer Business
Questions
•
Query
 Database object
 Stores criteria for selecting records from one or more
tables
 Save query
• Use it again
 More powerful than filter
• Display only some fields in table
• Create fields that perform calculations
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
10
XP
Using Queries to Answer Business
Questions (continued)
•
Capabilities of Access queries:
 Display selected fields and records from table
 Sort records on one or multiple fields
 Perform calculations
 Generate data for forms reports and other queries
 Update data in database
 Find and display data from two or more tables
 Create new tables
 Delete records in table based on one or more criteria
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
11
XP
Using Queries to Answer Business
Questions (continued)
•
Select query
 Ask question based on one or more tables in database
 Result displayed in datasheet
• Called recordset
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
12
Using the Simple Query Wizard XP
to
Create a Query
•
Simple query wizard
 Presents list of tables and queries in database
• And fields that they contain
 Select fields from one or more tables
 Wizard creates and displays results
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
13
XP
Advantages and Limitations of the
Simple Query Wizard
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
14
Including Summary Statistics inXPa
Query for Data Analysis
•
Summary query
 Groups records
 Calculate sum, average, minimum, or maximum value
in each selected field
 Count records in table or query
•
Click summary options button
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
15
XP
Creating a Summary Query with
the Simple Query Wizard
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
16
XP
Creating a Query in Design View
•
Select query window in Design view has two sections
 Area for field lists at top of window
 Design grid below it
•
Add tables for query to top part of window
 Appear as field lists
•
Query by example (QBE)
 Typing search value as a criterion
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
17
XP
Query Design View Tools
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
18
Creating Queries with MultipleXP
Criteria
•
•
Most queries involve more than one criterion
Represent AND criteria
 Entering conditions in same criteria row in query
design grid
•
Specify OR criteria
 Use “or” row of query design grid
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
19
XP
Setting Criteria for the Query in
Design View
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
20
XP
Specifying Sort Order in Queries
•
Query results appear in same order as data from
underlying tables
 Unless specify sort order when designing query
•
•
Sort order determined from left to right
Multiple columns must be adjacent to sort on more
than one field in datasheet view
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
21
XP
Running a Query
•
Click Run button on query design toolbar
 Access displays datasheet of records
•
Save query
 Save only design
 Not values from tables displayed in results
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
22
XP
Using Wildcards for Inexact Query
Matches
•
Wildcard character
 Placeholder
 Stands for one or more characters
•
Memo fields
 Use same keywords throughout memos
 Easily retrieve records later
 Use wildcards when specifying keyword as a query
criterion
• To select records that contain characters before and after
keyword
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
23
Wildcard Characters Used in XP
Queries
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
24
XP
Using Wildcards for Inexact Query
Matches (continued)
•
Access inserts
 Word “LIKE” for criteria with wildcards quotation marks
around text
• LIKE “*Spanish*”
 Pound signs around dates
• #12/*/2008#
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
25
XP
Comparison Operators
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
26
XP
Comparison Operators (continued)
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
27
Verifying and Printing Query XP
Results
•
Verify query results before
 Distributing query to others
 Using it as basis for decisions
•
Use business knowledge
 Determine whether results adequately answer question
•
Print query datasheet
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
28
XP
Modifying Query Datasheets
•
•
Improve appearance of query or table datasheet
Resize column widths in any datasheet
 Double-click line between field names to resize
columns to best fit
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
29
XP
Formatting Options for Query and
Table Datasheets
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
30
XP
Level 1 Summary
•
•
Use filtering and sorting to change data display
Develop queries using
 Simple query wizard
 Design view
•
•
Use comparison operators and wildcards to make
queries more flexible
Verify query results using business knowledge
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
31
XP
Level 2 Objectives:
Creating More Complex Queries
•
•
•
•
Design queries that compare data from more than
one table
Refine table relationships by specifying the join type
Perform calculations in queries
Customize queries and their results
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
32
Evaluating Data Using SpecialXP
Types of Queries
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
33
XP
Using Queries to Find Duplicate
Records
•
Duplicates Query Wizard
 Searches for duplicate values in fields
 Improve business operations
 Designed to identify records that contain same
information in particular field
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
34
XP
Using Queries to Find Unmatched
Records
•
Find Unmatched Query Wizard
 Compares records in two specified tables or recordsets
 Finds all records in one table or query that have no
related records in second table or query
 Requires that two tables being compared have
common field
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
35
XP
Limiting the Records in the Query
Results
•
•
Limiting results to only a few records often aids
analysis
Top Values query
 Sorts and then filters records
 Display specified number of records that contain top or
bottom values
 Top Values list box on query design toolbar
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
36
Top Values Query Design andXP
Results
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
37
XP
Using Parameter Values in Queries
•
Parameter values
 Phrase usually in form of a question or instruction
 Enclosed in square brackets
 Serves as prompt to user to enter value
 Example
• [Enter a job ID]
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
38
Parameter Query to Allow UserXP
Input when the Query Is Run
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
39
Analyzing Data from More thanXP
One Table
•
Data from more than one table required to answer
question
 Combine records from two or more tables
 Display only information needed
•
•
Work in design view to specify criteria for selecting
records from multiple tables
Lines between tables link primary key to foreign key
field
 Primary key designated with 1
 Foreign key designated with ∞
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
40
Analyzing Data from More thanXP
One Table (continued)
•
Join tables
 Linking of tables using primary and foreign keys
 Established relationship
 Or
• Each table shares field with same or compatible data
type
• One join field primary key
•
If tables do not include fields that can be joined
 Add one or more extra tables or queries
 Link tables that contain the data
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
41
Analyzing Data from More thanXP
One Table (continued)
•
•
Use queries as source of underlying data for another
query in place of one or more tables
Create queries based on more than one object
 Should not use any table or query that does not have
common field with at least one of the other tables or
queries
 Otherwise Access displays every combination of
records between two tables
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
42
XP
Refining Relationships with
Appropriate Join Types
•
Inner join
 Displays all records in one table that have
corresponding values in common field in another table
 Records must match before being displayed in query
results
•
Outer join
 Display all records of one table
 Regardless of whether corresponding record stored in
related table
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
43
XP
Inner Join
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
44
XP
Left Outer Join
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
45
XP
Right Outer Join
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
46
Refining Relationships with
Appropriate Join Types
(continued)
•
XP
Outer join types
 Left
 Right
•
Use join properties dialog box
 To change join type
 By default tables related using inner joins
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
47
Using Logical Operators to
Specify Multiple Conditions
•
XP
Logical operators
 Test values that can only be true or false
•
Place conditions in separate fields in same criteria
row of design grid
 All conditions in row must be met to select record
•
NOT logical operator
 Excludes values that don’t meet criterion
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
48
XP
Logical Operators
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
49
Performing Calculations withXP
Queries
•
Any information derived from fields in table or query
should be calculated in query
 Rather than included as data in table
•
Calculation types
 Predefined
• Compute amounts for groups of records or for all records
combined in query
 Custom
• Performs numeric date and text computations on each
record
• Using data from one or more fields
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
50
XP
Calculating Statistical Information
•
Aggregate functions
 Arithmetic and statistical operations
 Apply to records that meet query’s selection criteria
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
51
XP
Aggregate Functions
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
52
Using Aggregate Functions in XP
a
Query
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
53
Creating Calculated Fields in aXP
Query
•
Expression
 Arithmetic formula used to make calculation
 Use standard arithmetic operators
 Use parenthesis for complex expressions
•
Calculated field
 Add to query design grid
 Type expression
•
Expression builder
 Build complex expressions
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
54
Creating Calculated Fields in aXP
Query (continued)
•
Function
 Perform standard calculation
 Return value
•
Date()
 Provides today’s date
•
Field properties
 Change format and number of decimal places for
calculated field
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
55
XP
Field Properties
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
56
XP
Concatenating in Queries
•
Concatenation
 Combining contents of two or more fields
 Operator
• &
 Example
• Name [EmpFirst]& " " & [EmpLast]
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
57
XP
Level 2 Summary
•
•
Use queries to select data from more than one table
Join types
 Inner
 Right outer
 Left outer
•
Calculated field types
 Predefined
 Custom
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
58
Level 3 Objectives: Exploring XP
Advanced Queries and Queries Written
in Structured Query Language
•
•
•
•
Calculate and restructure data to improve analysis
Examine and create advanced types of queries
Make decisions in a query using the immediate IF
(IIF) function
Develop queries using SQL
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
59
XP
Analyzing Query Calculations
•
Crosstab queries
 Special type of totals query
 Performs aggregate function calculations on values of
one database field
 Determine exactly how summary data appears in
results
 Calculate and restructure data
• Analyze it more easily
 Work especially well with time-series data
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
60
XP
Creating a Crosstab Query
•
To create use
 Crosstab query wizard
• Often need to create query first
 Or design view
• Start with select query that includes numeric values or
summary calculations
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
61
XP
Crosstab Field Settings
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
62
XP
Modifying Data Using Queries
•
Action queries
 Modify data in table
 Add records to or delete records from table
 Create new table
•
Backup data before using action query
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
63
XP
Access Action Queries
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
64
XP
Process for Archiving Data
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
65
Archiving Data with Make-tableXP
Queries
•
Make-table query
 Creates table from some or all of the fields and records
in existing table or query
 Access does not delete selected fields and records
from existing table
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
66
Adding Records to Tables withXP
Append Queries
•
Append query
 Select records from one or more tables by setting




Chapter 3
criteria
Add those records to end of another table
Selected records also remain in original tables
Table to which records added must already exist
Also use to bring data from another source into
database
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
67
XP
Removing Records from Tables
with Delete Queries
•
Delete query
 Removes information from table
 Based on specified criteria
 All records meeting criteria permanently removed from
table
•
Create select query first
 Convert to delete query
•
Cascading deletes
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
68
Updating Data with an UpdateXP
Query
•
Update query
 Changes values of data in one or more existing tables
 Create select query first
• Change type to update query
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
69
XP
Making Decisions in Queries
•
IF statement
 Tests condition
 Takes one action if condition true
 Takes another action if condition false
•
IIF function
 Make if decision
 Format
• IIF(condition to test what to do if true, what to do if false)
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
70
Customizing Queries Using
Structured Query Language
•
XP
Access designed as database management system
(DBMS) for
 Small businesses
 Or departments within large businesses
•
Structured query language
 Common query language of most DBMSs
 Use to query, update, and manage relational
databases
•
Create query in design view
 Access translates entries and criteria into SQL
statements
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
71
Customizing Queries Using
Structured Query Language
(continued)
•
•
XP
View statements by switching from Design view to
SQL view
SELECT statement defines
 What data query should retrieve from database
 How it should present data
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
72
XP
Exploring the Components of an
SQL Query
•
Keywords
 Use to construct SQL statements
•
Most developers place each statement on separate
line
 To make SQL code easy to read
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
73
XP
Common SQL Keywords
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
74
XP
Level 3 Summary
•
Action queries
 Make new tables
 Append data
 Delete data
 Update data
•
•
IFF function
SQL
 Use SQL view to edit SQL directly
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
75
XP
Chapter Summary
•
Queries retrieve data from one or more tables
 Action queries update data
 Perform calculations
 Make decisions using IFF function
•
SQL
 Used to interact with relational databases
 Use SQL view to view/edit SQL statements generated
by Access
Chapter 3
Succeeding in Business with Microsoft Office
Access 2003: A Problem-Solving Approach
76