5.02 notes student

51
5.02 Notes Database Reports What is a database query, how is it used, and how does it differ from a filter? What is a form, how is it used and formatted, and how does it differ from a table? What is a database report? How is it used? What report components are used to control and enhance the appearance of the report and why? Database Objects I. Query. A query is a database object created by placing filters and selecting multiple criteria (comparison operators) to extract information from one or more tables. The resulting data becomes an object that can be saved, recalled, and used to perform other operations. A. Advantages of a Query 1. A query can be saved and used to perform other operations 2. One table can be associated with multiple queries 3. A query can perform specialized operations, such as performing calculations on field values, and placing the results in a new column or datasheet B. Difference Between a Query and a Filter 1. A filter is a one-time deal. It allows application of a set of selection criteria and/or sorting instructions to the records in a table. It is a quick temporary tool that is created for one-time use in the context of a particular table. 2. A query is reusable. It allows selection criteria and/or sorting instructions to be saved and reused. C. Comparison Operators used in Queries 1. Less than or equal to (<=) 2. Greater than or equal to (>=) 3. Not equal to (<>) 6411 – Computer Applications ISummer 2008, Version 2 Unit B – 5.02 page 448

Upload: wmassie

Post on 22-Nov-2014

2.831 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: 5.02 Notes Student

5.02 Notes Database Reports

• What is a database query, how is it used, and how does it differ from a filter?

• What is a form, how is it used and formatted, and how does it differ from a table?What is a database report? How is it used? What report components are used to control and enhance the appearance of the report and why?

Database Objects

I. Query. A query is a database object created by placing filters and selecting multiple criteria (comparison operators) to extract information from one or more tables. The resulting data becomes an object that can be saved, recalled, and used to perform other operations.

A. Advantages of a Query

1. A query can be saved and used to perform other operations

2. One table can be associated with multiple queries

3. A query can perform specialized operations, such as performing calculations on field values, and placing the results in a new column or datasheet

B. Difference Between a Query and a Filter

1. A filter is a one-time deal. It allows application of a set of selection criteria and/or sorting instructions to the records in a table. It is a quick temporary tool that is created for one-time use in the context of a particular table.

2. A query is reusable. It allows selection criteria and/or sorting instructions to be saved and reused.

C. Comparison Operators used in Queries

1. Less than or equal to (<=)

2. Greater than or equal to (>=)

3. Not equal to (<>)

4. Less than (<)

5. Greater than (>)

6. Equal to (=)

D. Conditional Operators

1. And – reduces the number of records because both conditions must be met.

2. Or – increases the number of records because one or the other condition must be met.

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 448

Page 2: 5.02 Notes Student

5.02 Notes Database Reports

II. Form. A form is a database object that is used to create a user-friendly format for data entry and retrieval. Forms may include drop-down menus, instructions, navigational controls, and graphics.

A. Advantages of Forms

1. Expedite the search and data entry processes

2. Easy to read and understand

3. Allow information to be censored

B. Common Elements of Forms

1. Graphics, such as lines, images, and shapes are stored in the form’s design.

2. Data displayed on forms is derived from the fields in the underlying table or query or may be added by the user.

3. Calculations are performed by properties that are set by a user within the form’s design.

4. Controls define how data can be entered, viewed, or used in calculations

5. Descriptive text can be added to a form for the purpose of identifying fields and forms or adding captions or prompts.

6. Subforms are forms within and related to a main form through a common field.

III. Report. A report is a database object used to organize, summarize, and print some or all of the data from one or more database tables or queries. It is used to present data in an attractive format with user selected fonts, colors, shading, borders, graphics, and other enhancements.

A. Advantages of Reports

1. Reports can group data from multiple tables, use the data in calculations, and add headings and other format enhancements to clarify database information.

2. Reports can be saved and updated.

3. Reports can be printed in landscape or portrait orientation.

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 449

Page 3: 5.02 Notes Student

5.02 Notes Reports

B. Report Components

1. Report header – appears once at the beginning of a report and usually contains items such as the company name, address, and logo.

2. Page header – appears at the top of every page and usually contains field names.

3. Group header – lists the field names in which the data is grouped

4. Detail section – contains the report details or content information; required

5. Group footer – used to display sums, counts, or averages of groups of data

6. Page footer – used to display page numbers and dates.

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 450

Page 4: 5.02 Notes Student

Q-F-R graphic organizerStudent Activity

Student Name Period Date

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 451

Page 5: 5.02 Notes Student

Q-F-R graphic organizerStudent Activity

Student Name Period Date

Q – F – R

A query is:

Advantages of a Query

1.

2.

3.

The difference between queries and filters:

Comparison Operators

Conditional Operators

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 452

Page 6: 5.02 Notes Student

Q-F-R graphic organizerStudent Activity

Student Name Period Date

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 453

Page 7: 5.02 Notes Student

Guided Practice: Query: B&B DatabaseTeacher Demonstration

Student Name Period Date

GUIDED PRACTICE: QUERY: B & B DATABASE

Directions: In this activity, you will follow along with your teacher to query a database. Using the B&B database and the HistoricInns table last edited in Objective 5.01, create and name the following queries. Be certain that only the desired fields are shown in the results of the query.

Instructions for Query 1:

1. Query for records that meet the following conditions and save it as Choice:

Name of inn in ascending order Greater than 4 rooms available AND Located in the city AND Allows children.

Field Inn Rooms Children City

Sort Ascending

Criteria >4 =yes =yes

Record the steps for creating the query below:

2. Look at the bottom of the query in design view and notice that no filter has been applied. This means that the query has extracted the data from the Historic Inns table and placed it into the Choices query. As far as this query is concerned, the remaining data no longer exists.

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 454

Page 8: 5.02 Notes Student

Guided Practice: Query: B&B DatabaseTeacher Demonstration

Student Name Period Date

3. Save and close the query

4. Select the Historic Inns table and perform an advanced filter/sort using the following criteria and sort order.

Field Inn Rooms Children City

Sort Ascending

Criteria >4 =yes =yes

Record the steps for creating the filter below:

5. Once the filter has been applied, are the results the same as the query?

6. What happens when you try to save the filter?

7. Look at the bottom of the filter and notice that the Filtered box is highlighted (or active). This means that the filter has hidden the data from the Historic Inns table that does not match the criteria. If you click on the filtered box to turn the filter off, the hidden records will reappear.

8. In your own words, summarize the difference between a query and a filter.

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 455

Page 9: 5.02 Notes Student

Guided Practice: Query: B&B DatabaseTeacher Demonstration

Student Name Period Date

Instructions for Query 2:

1. Query the Historic Inns and Location tables for the following information:

Historic Inns Table Name of inn in ascending order Less than 10 rooms available AND Located in the city (do not show this field) AND Allows petsLocation Table Street City State Zip Phone

Table Historic Inns Location

Field Inn Rooms

City Pets Street City State Zip Phone

Sort Ascending

Criteria

<10 =yes =yes

2. Save the query as Pets.

3. Describe the results.

a. What are the names of the Inns?

b. Which inns have the same number of rooms?

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 456

Page 10: 5.02 Notes Student

Guided Practice: Query: B&B DatabaseTeacher Demonstration

Student Name Period Date

c. Which inns have the same zip code?

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 457

Page 11: 5.02 Notes Student

Guided Practice: Query: B&B DatabaseTeacher Key

GUIDED PRACTICE: QUERY: B & B DATABASE KEY

Query 1

Query 2

5. Once the filter has been applied, are the results the same as the query? Yes

6. What happens when you try to save the filter?.The whole table is saved

3a. Names of the inns:..........................Abbington, Biltmore, Blake, Carolina

3b. Inns with the same number of rooms.........................Biltmore and Blake

3c. Inns with the same zip code................................Abbington and Carolina

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 458

Difference between query and filter:

A query provides permanent listing of only the information requested whereas the filter provides all information, but simply hides fields that are not requested. A filter is not permanent. A filter can be applied to a query.

Page 12: 5.02 Notes Student

Guided Practice: Query: B&B DatabaseTeacher Key

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 459

Page 13: 5.02 Notes Student

Independent Practice: Query: Pet Registry Database Student Activity

Student Name Period Date

INDEPENDENT PRACTICE: QUERY: PET REGISTRY DATABASE

Directions: In this activity, you will work independently to query a database. Using the Pet Registry database last edited in Objective 5.01, create and name the queries listed below. Be certain that only the desired fields are shown in the results of the query. Save and submit your work according to teacher instructions.

Query 1:

1. Query the PetRoster table for the sort order and criteria listed below. Save the query as LargeBreed and answer the questions that follow.

Pedigree in ascending order AND Adoption date after 3/29/2009 AND Weight greater than 70 lbs.

Field Pedigree Adoption Date Weight

Sort Ascending

Criteria >3/29/2009 >70

2. Perform an advanced filter on the query for large breeds weighing more than 100 lbs.

Questions for Query 1

1. How many records resulted from the query?

2. How many breeds?

3. What is the latest date of adoption?

4. How many records resulted from the filter?

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 460

Page 14: 5.02 Notes Student

Independent Practice: Query: Pet Registry Database Student Activity

Student Name Period Date

5. What is the effect of filtering a query?

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 461

Page 15: 5.02 Notes Student

Independent Practice: Query: Pet Registry Database Student Activity

Student Name Period Date

Query 2:

1. Query the PetRoster and PetOwners tables for the sort order and criteria listed below.

Pedigrees equaling Doberman Pinscher, Mastif, or Rottweiler in ascending order

Owner Name Owner Street Owner City Owner State Owner Zip

Table Pet Roster Pet Owners

Field Pedigree Owner Name

Owner Street

Owner City

Owner State

Owner Zip

Sort Ascending Ascending

Criteria

=Doberman Pinscher

OR Mastif

Rottweiler

2. Save the query as Power Breeds and answer the following questions.

Questions for Query 2

1. How many records resulted from the query?

2. How many of each breed?

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 462

Page 16: 5.02 Notes Student

Independent Practice: Query: Pet Registry Database Teacher Key

INDEPENDENT PRACTICE: QUERY: PET REGISTRY DATABASE KEY

Query 1

1. How many records resulted from the query?

14

2. How many breeds?

14

3. What is the latest date of adoption?

12/25/2009

4. How many records resulted from the filter?

8

5. What is the effect of filtering a query?

It further refines the data.

Query 2

1. How many records resulted from the query?......................................................3

2. How many of each breed?..................................................................................1

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 463

Page 17: 5.02 Notes Student

Q-F-R graphic organizerStudent Activity

Student Name Period Date

Q – F – R

A form is:

Uses:

Advantages of a Form:

1.

2.

3.

4.

Common Elements of Forms:

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 464

Page 18: 5.02 Notes Student

Q-F-R graphic organizerStudent Activity

Student Name Period Date

6411 – Computer Applications I Summer 2008, Version 2 Unit B – 5.02 page 465

Page 19: 5.02 Notes Student

Guided Practice: FormsTeacher Demonstration

Student Name Period Date

GUIDED PRACTICE: FORMS

Directions: For this activity, you will follow along with your teacher to take notes and create a form.

1. Design an address book database using the fields and field types listed. Name the database AddressBook and the table Contacts. Once you have created the database, save and close. You will add records to the table after a form has been created.

Field NameData Type

Properties

Last Text 15

First Text 10

Street Text 25

City Text 20

State Text 3

ZIP Text 10

Home Phone Text Use Input Mask to format phone number

Work Phone Text Use Input Mask to format phone number

Cell Phone Text Use Input Mask to format phone number

Birthday Date Short Date

Anniversary Date Short Date

Business Text 50

Contact Type Text Look Up Field (friend, family, business)

Notes:

Page 20: 5.02 Notes Student

Guided Practice: FormsTeacher Demonstration

Student Name Period Date

2. Create a form and save it as Contacts or according to teacher directions.

Notes:

3. Enhance the form’s design by including some of the following modifications:

a. Arrange the fields into a design that is both attractive and allows for easy data input

b. Change the background color

c. Add a graphic

d. Format the labels by changing font color/size

e. Add a header label indicating the address book owner’s name

Notes:

Page 21: 5.02 Notes Student

Guided Practice: FormsTeacher Demonstration

Student Name Period Date

Note the example forms demonstrating font style changes, header added, background color change, and rearranged fields.

Page 22: 5.02 Notes Student

Guided Practice: FormsTeacher Demonstration

Student Name Period Date

4. Enter data into the address book using the form. In addition to the contacts listed in the table, add five personal entries for a total of 15 records in the database.

Name and AddressHome/Work/Cell

PhonesBirthday

AnniversaryBusiness

(if any)Type of Contact

Ronnie Caldwell6019 Sand Hill RoadHot Springs, NC 28743

H-828-555-1232C-828-555-2321

B-Feb. 19, 1987 Friend

John Bond437 Nathan DriveBeech Mountain, NC 28604

W-828-555-2574C-828-555-1122

Bond’s Used Cars

Business

Dee Dee Trilling56 College StreetAtlanta, GA 30301

H-678-555-8858C-678-555-3312W-678-555-2577

B-June 3, 1981A-July 1, 2005

Williams and Willis

CompanyFamily

Edward Jones56 Central AvenueDurham, NC 27722

H-919-555-2264C-919-555-4622W-919-555-9992

B-Nov. 22, 1960

A-June 15, 1988

Computer Controls

Family

Sandra English13245 Cowboys LaneDallas, TX 75222

C-903-555-3124W-903-555-4213

Acme Web Designers

Business

Lynn Keith29 North Market StreetAsheville, NC 28801

H-828-555-1414C-828-555-6379W-828-555-2507

B-March 3, 1990

Carolina Tractor

CompanyFriend

Melinda Owens226 HazelKnoxville, TN 37902

H-865-555-9651 B-May 23, 1995 Family

Keith Black44 Columbia RoadCamden, SC 29020

H-803-555-9611C-803-555-1217W-803-555-3627

Bilt-Rite Buildings

Business

Brenda Fisher19 Orchard CircleCharlotte, NC 28212

C-704-555-3212W-704-555-2020

Carolina Fine Furnishings

Business

Wayne Anderson1056 Bailey StreetRaleigh, NC 27634

H-919-555-1976C-919-555-6565W-919-555-4185

B-Dec. 2, 1988A-Jan. 1, 2005

Ace Hardware Friend

Notes:

Page 23: 5.02 Notes Student

Guided Practice: FormsTeacher Demonstration

Student Name Period Date

5. Sort the forms in ascending order by name (last, first). Print the data table.

6. Find the record for Wayne Anderson and change the cell phone number to 555-7256. Print this individual form.

Notes:

7. Filter the records for Friends. Sort these records in ascending order and print the last form.

Notes:

Page 24: 5.02 Notes Student

Guided Practice: FormsTeacher Key

GUIDED PRACTICE: FORMS KEY

Printed form for Wayne Anderson

Printed form of last Friend in sort Student answers will vary.

Page 25: 5.02 Notes Student

Independent Practice: FormsStudent Activity

Student Name Period Date

INDEPENDENT PRACTICE: FORMS

Directions: In this activity, you will work independently to create a database form and add entries.

1. Open the Customers table from the United Grocers database that has been sent to you electronically by your teacher.

2. Save the database to your files.

3. Create a form using all fields in the customers table

4. Set the Store ID as the primary key

5. Make any design changes you wish, but make sure all data is aligned to the left

6. Save the form as Customers

7. Add the following records using the form just created and then save and submit according to teacher directions

Page 26: 5.02 Notes Student

Independent Practice: FormsTeacher Key

INDEPENDENT PRACTICE: FORMS KEY

In this activity, you will work independently to create a database form and add entries

Page 27: 5.02 Notes Student

Guided Practice: Add SubformsTeacher Demonstration

Student Name Period Date

GUIDED PRACTICE: ADD SUBFORMS

Directions: The goal of this activity is to add a subform to the Customers form created in the previous activity. You will follow along with your teacher and the Forms and Subforms PowerPoint to complete this activity.

1. Open the United Grocers database that has been sent to you electronically by your teacher and save it to your files

2. The United Grocers database should contain four tables (Slide 2):

a. Purchase Orders

b. Orders

c. Customers

d. Grocery Products

3. Before the subform is created, it must be planned. What information is desired? What information is required in order to extract the desired information?

4. Queries are an easy way to extract data for use in subforms.

5. View Slide 3 to understand the building blocks of the query and how each table is dependent upon and related to its neighbor.

6. View Slides 4 and 5 to understand why certain fields are required in the query.

7. One additional field must be included in the query so that the subform will communicate with the main form. View Slide 6.

8. Create a query using the tables and fields below and save the query as Customers Query

Table Customers Orders Purchase Orders Grocery Products

Field Store ID Store ID

Order No

Order Date

Order No.

Quantity ISBN ISBN Unit Pric

e

Product

9. View the query results on Slide 7

10. Open the Customers form in design view (Slide 8)

11. Insert a subform to the right of the customer data

12. Select the option to use existing queries and select the Customers Query

13. Include the following fields from the query:

a. Customers_Store ID

b. Orders_Order No

Page 28: 5.02 Notes Student

Guided Practice: Add SubformsTeacher Demonstration

Student Name Period Date

c. Order date

d. Purchase Orders_ISBN

e. Quantity

f. Unit Price

g. Product

14. Select the option to show customers query for each record in customers using store ID

15. View Slide 9 for a graphic of the subform in design view

16. Open the properties menu on the subform and set the default view for the subform to single form (Slide 10)

17. View the form and verify that the subforms are consistent with the main forms (Slide 11)

a. Record 1 of the main form is for Harris Teeter, Store ID 410432

b. Record 1 of the subform is for the same store, Order No 1

c. Record 2 of the subform is for the same store, Order No 3

18. View Slide 12 to see the subform and main form for a different store

Page 29: 5.02 Notes Student

Independent Practice: Add SubformsStudent Activity

Student Name Period Date

INDEPENDENT PRACTICE: ADD SUBFORMS

Directions: In this activity, you will work independently to add a subform. The subform will be the result of a query created from the two tables you will create below.

1. Create a new database and name it Hair

2. Create a table and enter the records below. Save the table as Prices and set the ID field as the primary key.

3. Create another table and enter the records below.

a. Save the table as Orders.

b. Use the PO# field as the primary key and use AutoNumber.

c. Use the lookup property to retrieve the products from the Prices table and enter them in the Product field.

Notes:

Page 30: 5.02 Notes Student

Independent Practice: Add SubformsStudent Activity

Student Name Period Date

4. Create a query named Orders and include the following fields:

a. Orders table:

i. PO #ii. Customeriii. Quantityiv. Product

b. Prices table: Include only the Prices field

5. Establish the relationships indicated in the graphic below:

6. Create a main form from the Orders table that includes only the Customer field.

7. Create a subform using the Orders query that includes all fields.

a. Adjust the size of the subform to fit attractively within the main form.

b. Set the view property to continuous forms.

8. Describe the process used to complete this activity.

9. Save and submit your work according to teacher directions.

Page 31: 5.02 Notes Student

Independent Practice: Add SubformsStudent Activity

Student Name Period Date

Page 32: 5.02 Notes Student

Independent Practice: Add SubformsTeacher Key

INDEPENDENT PRACTICE: ADD SUBFORMS KEY

Page 33: 5.02 Notes Student

Q-F-R graphic organizerStudent Activity

Student Name Period Date

Q – F – R

Report Components

Header Section

Report header

Page header

Group header

Detail section

Footer Section

Page footer

Group footer

A database report is

Common Uses:

Advantages:

Page 34: 5.02 Notes Student

Q-F-R graphic organizerStudent Activity

Student Name Period Date

Identify the Parts of the Report

2.

4.

5.

6.

1.

3.3

1

2

4

6

5

Page 35: 5.02 Notes Student

Guided Practice: ReportsTeacher Demonstration

Student Name Period Date

GUIDED PRACTICE: REPORTS

In this activity, you will follow along with your teacher to prepare mailing labels and a report from the United Grocers database.

Labels

1. Select the option to create labels

2. Select the Customers database table

3. Select Avery, product number 5160

4. Select font size and weight (12 pt, Normal)

5. Select all fields from the Customers Table except Manage and Phone and align them on the prototype label

6. Sort by the Store Name

7. Save the labels as Customer Labels and view

Report

1. Create a report using the following fields from the Products table

a. ISBN

b. Product

c. Category

d. Unit Price

e. Quantity per Unit

2. Select the option to group the data by category and to sort the data in ascending order by product name

3. Grab and move the Unit Price column in front of the ISBN column

4. Make any enhancements to the report

5. Save

Page 36: 5.02 Notes Student

Guided Practice: ReportsTeacher Demonstration

Student Name Period Date

Page 37: 5.02 Notes Student

Guided Practice: ReportsTeacher Key

GUIDED PRACTICE: REPORTS KEY

For a clear view of this document, view the report in the United Grocers Database

Page 38: 5.02 Notes Student

Guided Practice: ReportsTeacher Key

Page 39: 5.02 Notes Student

Independent Practice: ReportsStudent Activity

Student Name Period Date

INDEPENDENT PRACTICE: REPORTS

Directions: In this activity, you will work independently to create two reports. Once you have created the report, add enhancements that make the form attractive and user-friendly.

You will need the Pet Registry database to complete this report.

The Moore County Animal Shelter wants to view a report of all adoptions in the database to analyze the data and determine when and what kind of dogs are most often adopted.

1. Create a query saved as Report Query that is sorted according to the following criteria:

a. PetOwners table

i. Owner ID

ii. Name

iii. Street

iv. City

v. State

vi. Zip

b. Pet Roster table

i. Pedigree

ii. Adoption Date

2. Create a report using all of the fields in the query.

a. The report should be grouped by Pet Roster first and Adoption Date second.

b. Sort the data by adoption date and sorted by Pedigree and Owner Name, both in ascending order.

c. Format the report to print in landscape view.

d. Key Adoption Trends as the header of the report and save it by the same.

Page 40: 5.02 Notes Student

Independent Practice: ReportsTeacher Key

INDEPENDENT PRACTICE: REPORTS KEY For a clear view of this data, view the report in the Pet Registry Database