part i. open a access database blank database database wizard existing database (last five databases...

71
Part I

Upload: augustus-oneal

Post on 08-Jan-2018

231 views

Category:

Documents


0 download

DESCRIPTION

The database window This window will appear after selecting the database. Note it has the 6 database objects each on its own tab.

TRANSCRIPT

Page 1: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Part I

Page 2: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Open a Access Database• Blank Database• Database Wizard• Existing Database

(last five databases saved on the computer appear in the list box. If the file you want does not appear select More files…)

Page 3: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

The database window

• This window will appear after selecting the database. Note it has the 6 database objects each on its own tab.

Page 4: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Database Tables

• Used to store data • holds field names,

field descriptions and data for each field of each record

• underlying structure for data stored in a database

Page 5: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Table Selection

• Datasheet View• Design View• Table Wizard• Import Table• Link Table

Page 6: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Design ViewDatabase Table

Page 7: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Columns in the Table Design

• Field Name• Data Type - 10 types that are listed in a

drop down box by clicking the arrow button on the column

• Description

Page 8: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Access Data Types

• Text - any combination of alphabetic and numeric characters, such as names, addresses, and telephone numbers, that are not use in calculations (default)

• memo - long entries requiring multiple lines of text, such as detailed descriptions and performance notes

Page 9: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Access Data Types

• Number - numeric values, such as the number of items or number of days worked that might be used in calculations

• Date/Time - dates, such as date hired, and times, such as 1:00

• Currency - monetary values, such as salary

Page 10: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Access Data Types

• AutoNumber - numbers assigned by Access to uniquely identify each record; these values cannot be changed, deleted, or edited

• Yes/No - Single-character entry fields that are marked when the status of the field is true (yes) or left blank when the status is false (no)

Page 11: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Access Data Types• OLE object - fields that may be linked to an

object, such as a picture or a document• Hyperlink - fields linked to other objects,

Web pages, or documents that appear when the field when the field is clicked.

• Lookup Wizard - fields that enable you to access a value from a table or list of values

Page 12: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Filled in Table Design

Page 13: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Datasheet View

The Field Name(s)

There are no records for this Database (yet)

Page 14: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Records Added to Datasheet

Page 15: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Two Views

• Datasheet view - you see the field names as column headings and records as row. View multiple records on the screen.

• Form view - forms use the fields and data that are stored in database tables to see one record on-screen at a time.

Page 16: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Form View

Page 17: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Maintenance

• Change is inevitable. You will need add, delete modify information in your db

• find, update, insert, replace, delete, sort, and filter and query.

Page 18: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Find, Filter, Query

Query languageformat

examples

Page 19: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Query Language

• ask questions about the database• find the records which match a certain

criteria

Page 20: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Find or Filter or Query

• Which one? Depends on preciseness.• All display or filter only the record(s) that

match a specific criteria • note that there is also a FIND command in

the word processing and spreadsheet tools.

Page 21: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Find• usually used for error correction • used in searching for a particular value in a record.

This command works the same way as it did for the spreadsheet.

• you type in the dialog box • Find what: the entry you want to find. Depending

on whether you unselected “current field”, Find searches each field (in the table) to look for a match.

Page 22: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

To Find Records in a DB Table• The binoculars on the toolbar• also can do find/replace (Edit->Replace)

Page 23: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Find

• Find can a search criterion with text or values anywhere in the table. This can be inexact. For example, if you used the find command to find an employee named Brown, the records of employees who live in the town Brown or on the street Brown could also be displayed.

Page 24: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Filters

• A Filter is an exact match. In a filter, Access only matches within a certain field. So in our last example, you would tell Access to find only NAMES (the field name) that are equal to Brown. Thus the other Brown matches are eliminated.

Page 25: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Filters• To display (filter) only the record or records

that satisfy a criterion.• Filter by selection is the simplest type of filter.• All you need to do is give Access an example

of the data you want by selecting the data within the table, and then clicking the Filter by Selection button on the Form View toolbar (the sieve with the lighting bolt)

Page 26: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Filter

• In order to have all the records once again displayed, you remove the filter by clicking the Remove Filter button on the form toolbar. ( the sieve by itself icon)

Page 27: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Filter/Query• Not saved• only within a single

table• displays all the fields

of “filtered” records• no other functions

• Can be saved (it is one of the 6 objects)

• multiple tables• displays only the fields

you specified• queries can also be used

to insert new values, modify field values and perform calculations on field values

Page 28: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Database WindowQueries Tab

Three options you can do in queries section

Previously Saved queries

Page 29: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Queries• Click on tab marked Queries on the

Database Window• There are three button on this window:

– Open - If a previously saved query is highlighted, clicking this button will display the results of this query.

– Design - If a previously saved query is highlighted, clicking this button will display the design query window filled in with the settings for this query.

– New - An empty design query window will be displayed

Page 30: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Queries• Note the table(s) used in the query display at

the top. • If you clicked the Design button, the table(s)

used in this saved query will be displayed.• If you clicked the New button, you will be

given the opportunity of selecting the tables through the Show Table.

Page 31: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Show Table

Tables saved for this database

To add tables to the query, highlight the table name and click Add. When finished click Close

Page 32: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Query Design Window

Back to Queries slide

Page 33: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

The Query Design Window• A Window that isolates the important parts of a query. (Design view) • Two Important parts to the Window:

– Table(s) used in the query (top half)– The Query Grid

...

Page 34: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Parts of the Query Design Window

the table(s) used in the query

Customers

*

Customer Id

First Name

Last Name

Address

Table name

Example of a selected table to use in a query, appears in the top half of the Query Design Window

Field Names

Page 35: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Parts of the Query Design Window

the query grid

Field:Table:Sort:Show:CriteriaOr:

Drop down box of the Field Names from the selected tables

Page 36: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Field

• Drop down box, depends on the tables you selected to include either when the show table dialog box appeared (New) or from the original query (Design) . Once selected, the fields from the selected tables will be used in the query.

Page 37: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Table:

• You can select several tables for a query operation.

• Once you have selected the Field , this entry is automatically entered by Access. Access will enter the table name of the field you selected.

Page 38: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Sort: • You have the option of sorting the matching records• Just left click on the box and a drop down menu will

appear,• Ascending, Descending and none• Can sort on more than one field, the first field listed

(the leftmost) is the major key.• Remember only the query is sorted not the original

table(s)

Page 39: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Show:

• If you want this field data to appear in the results

• An empty Show box indicates that the field data will not appear in query results.

• A checked Show box indicates that the field data will appear in query results.

• Objective: remove unnecessary or duplicate fields

Page 40: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Criteria

• The final part, the criteria, (the comparison), determines how the query will do its comparisons.

• Using expressions (just like Excel), combinations of field names, constant values, arithmetic and logic operators, you can restrict the number of records returned by a query

Page 41: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Our Question (Query)?

Customers

*

Customer Id

First Name

Last Name

Address

Who are our customers with the first name of John? (list them alphabetically)

Select the Customers database

This can be answered by a completing a Query Design Window.

Page 42: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Filled in Query Design Window to Answer our

Question

Field:Table:Sort:Show:CriteriaOr:

Customers

*

Customer Id

First Name

Last Name

Address

Display in alphabetical order the last names of customers with the first name of John

First NameCustomers

Ascending

“John”

Last NameCustomers

Page 43: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

The Results• A list will appear when the run command is

clicked, the ! Icon.Last Name

Black

Braithwaite

Dewey

Dickenson

Dobbins

Duran*

Only Last Name field data displays

Also note that the Johnaton(s) are not listed

Must use wild cards *

“John*”

Page 44: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

• When you entered in the string John, Access will automatically place the quotes

• John “John”• If you entered the string John*, Access will

automatically change the field to • John* Like “John*”• Or you can put these in yourself.

Access Automatic “FILL”

Page 45: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

String Criteria• We can “match” strings for text type fields• We can use the wild cards * and ? for substitution of characters• * - 0 or more character substitution• Like “John*”

– matches John, Johnaton, Johns, Johnstone– but not Jon, Jjohn

• ? only one match and not anymore • Like “285?5???”

– matches 285 5555, 285- 5555 – but not 765-285-5555, 1-285-5555, 285-51111

Page 46: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Our Next Question?

Customers

*

Customer Id

First Name

Last Name

Address

Who are our customers with the first name of John or Susan? (list them alphabetically)

Our database

This can be answered by a completing a Query Design Window.

Page 47: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Design Query

Field:Table:Sort:Show:CriteriaOr:

Customers

*

Customer Id

First Name

Last Name

Address

Display in alphabetical order the last names of customers with the first name of John or Susan

First NameCustomers

Ascending

“John”

Last NameCustomers

“Susan”

Page 48: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

The Results• A list will appear when the run command is

clicked, the ! Icon.Last Name

Black

Braithwaite

Dewey

Dickenson

Dobbins

Duran

Doolittle*

Only Last Name field data displays

Also you note that the Johnaton(s) and Susanne(s) are not listed.

Must use wild cards * in strings “John*” “Susan*”

Page 49: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

OR

• connectors• allows you to link comparisons to make it

possible for you to analyze data in various ways

• logical operators, because they act in comparisons the way mathematical operators work in the Spreadsheet

Page 50: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Or Conjunction

• when one or more of the conditions needs to be “true” we use the or conjunction

• color equal to green OR color equal to yellow • color equal to green OR part number equal to

948• one listed in the criteria row, the other in the

or row

Page 51: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Numeric Criteria - Logic Operators

• Greater than (>)• Less than (<)• equals (=)• greater than or equal to (>=)• less than or equal to (<=• not equal to (<>• (same as Excel If expressions)

Page 52: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Design Query

Field:Table:Sort:Show:CriteriaOr:

Customers

*

Customer Id

First Name

Last Name

Address

Total Purchase

Age

Tablename

Display in descending order the total purchase ofcustomers who are under 30 years of age

Total PurchaseCustomers Customers CustomersDescending

Last Name Age

<30

Page 53: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

The Results• A list will appear when the run command is

clicked, the ! Icon.

Total Purchase

$1900.50

$1410.26

$1167.88

$900.88

$469.34

$367.99*

The query is sorted by the amount of the total purchase

Last Name

Smith

Buy

Jones

Smith

Feather

Johnson

Age

24

21

26

20

14

29

Page 54: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Design Query

Field:Table:Sort:Show:CriteriaOr:

Orders

*

Customer Id

Order #

Product ID #

Quantity

Unit Price

Date of Purchase

Date of Payment

Tablename

Display all orders which have not been paid by oldest date

Order #Orders Orders Orders

Date of Purchase Date of Payment

Is Null

Ascending

Page 55: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Criteria

• Null - the absence of data - an empty field. • If a field has no entry, it is called a null

value. This is not the same as a space or zero!

• The computer treats dates as if they were sequential numbers that increase with time

Page 56: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

The Results• A list will appear when the run command is

clicked, the ! Icon.

Order #

146678

145778

145807

145900

145910

145950*

The query is sorted by the date of purchase

Note that the Date of Payment could have been marked to not display.

Date of Purchase

3/10/2000

3/12/2000

3/15/2000

3/19/2000

3/21/2000

3/24/2000

Date of Payment

Page 57: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Design Query

Field:Table:Sort:Show:CriteriaOr:

Orders

*

Customer Id

Order #

Product ID #

Quantity

Unit Price

Date of Purchase

Date of Payment

Tablename

Display all orders which were paid this month

Order #Orders Orders Orders

Date of Purchase Date of Payment

>=4/1/2000

Ascending

Page 58: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

The Results• A list will appear when the run command is

clicked, the ! Icon.

Order #

146578

145578

145607

145600

145710

145750*

The query is sorted by the date of purchase

Note that the Date of Payment could have been marked to not display.

Date of Purchase

3/02/2000

3/02/2000

3/05/2000

3/05/2000

3/06/2000

3/06/2000

Date of Payment

4/2/2000

4/2/2000

4/4/2000

4/5/2000

4/6/2000

4/6/2000

Page 59: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

• When you entered in the string >4/1/2000, Access will automatically place the # s

• >=4/1/2000 >=#4/1/2000#• Or you can put these in yourself.

Access Automatic “FILL”

Page 60: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Simple Selection Query

Field:Table:Sort:Show:CriteriaOr:

Customers

*

Customer Id

First Name

Last Name

Address

Display all of the customers with the nameJohn Smith

First NameCustomers

“John”

Last NameCustomers

“Smith”

Page 61: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

And Conjunction

• The AND conjunction says that both conditions must be present for the record (row) to be queried

• to combine criteria with AND, place the criteria on the same line

Page 62: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Combining Multiple Conjunctions

• when combining with all Ors - no problem• when combining with all Ands - no problem• when combining with both Ands and Ors -

order is important

Page 63: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Design QueryCustomers

*

Customer Id

First Name

Last Name

Age

Display in alphabetical order the last names of customers with the first name of John or Susan that are older than 50 years of age.

Field:Table:Sort:Show:CriteriaOr:

First NameCustomers

“John”

Ascending

Last NameCustomers

“Susan”

AgeCustomers

>50

Page 64: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

First Name Last Name Age

David Done 33

Fred Flinstone 55

Susan Johnson 43

Susan Peters 34

John Peters 39

John Smith 55

Susan Smith 52

The Records in the Database

Page 65: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

First Name Last Name Age

Susan Johnson 43

Susan Peters 34

John Smith 55

Susan Smith 52

Result of Query

Note that the records matched any record with the first name of Susan and records that had the first name of John and were older than 50

(FirstName = “John” AND Age > 50) OR FirstName = “Susan”

Page 66: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

First Name Last Name Age

John Smith 55

Susan Smith 52

But what if wanted only those records with first name of Susan who were age 50 or older or records with the first name of John who were age 50 or older … or

Note that the records matched any record with the first name of Susan and records that had the first name of John and were older than 50

(FirstName = “John” OR FirstName = “Susan”) AND age > 50

Page 67: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Design QueryCustomers

*

Customer Id

First Name

Last Name

Age

Display in alphabetical order the last names of customers with the first name of John or Susan that are older than 50 years of age.

Field:Table:Sort:Show:CriteriaOr:

First NameCustomers

“John”

Ascending

Last NameCustomers

“Susan”

AgeCustomers

>50

>50

Page 68: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

First Name Last Name Age

John Smith 55

Susan Smith 52

Result:

Note that the records matched any record with the first name of Susan who was older than 50 years of age or records that had the first name of John who were older than 50 years of age.

(FirstName = “John” and age > 50) OR

( FirstName = “Susan” and age > 50)

Page 69: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Three fields using AND and OR

Page 70: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Meaning

• Be careful of the wording when designing queries.

• For example if I asked you to give me a list of classes that are held at 9:00 A.M and 10:00 A.M, I am using the word AND to mean both (not the connective AND)

• BOTH-> OR

Page 71: Part I. Open a Access Database Blank Database Database Wizard Existing Database (last five databases saved on the computer appear in the list box. If

Questions