Date post: | 10-Apr-2018 |
Category: |
Documents |
Upload: | benjamined |
View: | 219 times |
Download: | 0 times |
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 1/53
Microsoft Access 2007 Tutorial
(Part
I)CIS*1000*DE
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 2/53
What’s a Database?
• A Database is a collection of related
items/facts/data arranged
in
a specific
structure.
• Some examples of databases include: – Dictionaries
– Phonebooks
or
Telephone
Directories
– The Periodic Table of Elements
– TV Guide
– The Sears Christmas Wishbook
– Leonard Maltin's Movie Encyclopedia: CareerProfiles of More Than 2,000 Actors and
Filmmakers, Past and Present
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 3/53
Why Use Databases?
• Businesses use databases to keep track of their inventories,
clientele,
employees,
sales,
expenses,
and to create and manage online stores, etc.
• Libraries use databases to keep track of their books,
periodicals, journal
articles,
and
borrowed
materials.
• Universities use databases to keep track of student fees, registration, transcripts, course information,
etc.• The Government uses databases to keep
track of YOU (think census statistics).
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 4/53
Data Organization
Field A basic fact or data element such as a
name or number.
Record A set of related fields.
Table A group of related records.
Database A collection of one or more related tables.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 5/53
StudentsStudent ID
Last Name
Program
First Name
EnrollmentStudent ID
Course Synonym
Semester
Courses
Credit WeightProfessor’s Name
Course Code
Course Synonym
Email Address
Data Organization cont’d
Field Names
Table Names
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 6/53
Data Organization cont’d
• Recall that a record is a set of related
fields.• Each record contains the same fields
but with different information. – For
example,
different
students
will
have
different names, student ID #’s, etc…
• Each table usually contains a field, called the Primary Key , that uniquely
identifies each
Record.
• Multiple Tables can be linked together by using a common field.
StudentsStudent ID
First Name
Last NameEmail Address
Program
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 7/53
StudentsStudent ID
Last Name
Program
First Name
EnrollmentStudent ID
Course Synonym
Semester
Courses
Credit Weight
Professor’s Name
Course Code
Course Synonym
Email Address
Data Organization cont’d
• Primary Keys: Student ID, Course Synonym
• Common Fields: Student ID, Course Synonym
Relationship Lines
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 8/53
Microsoft Access
• Microsoft Access is an application that
allows
us
to
create
small
databases.
• In this lab we’re going to create a simple
database that
contains
two
tables:
1. Students
2. Cities
• But first…
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 9/53
Open Microsoft Access 2007
START
PROGRAMS
Double click on
the ICON
on
desktop
OR
Microsoft Access 2007
Microsoft Access 2007
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 10/53
Getting Started
• Select Blank Database
•
Create the
database
as
“Test”
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 11/53
Saving your
Database
• To save your
document, simply click
on the MS 2007 logo in
the top left‐hand corner
[
] and
the
menu
bar
that you see on your
right here will drop down
giving you
various
options, including saving.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 12/53
Saving your Database cont’d
• When you save a database in MS
Access
2007,
it
automatically
saves with “.accdb” as its
extension.
• However, you can also save your
database so that it’s readable by
earlier versions of MS Access
(2000, 2002
– 2003)
by
simply
going to “Save As” and choosing
to save the database in a different
format from a previous version of
MS Access.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 13/53
*** A Cautionary Note ***
• There is an inherent danger with working off a floppy disk or a
USB key with
a MS
Access
database.
• When a file is opened with Access, a bunch of stuff from the file is
unpacked and is NOT put back until the file is closed.
• Meaning, IF working
from
a floppy
disk
or
a USB
key,
DO
NOT
eject your disk or USB key until you close MS Access first.
• In fact, working off floppy disks & USB keys should be avoided all
together.
• Instead, work off the computer and when you’ve finished your
work and closed down MS Access, copy your database to a floppy
disk or
USB
key.
• And as always, make backups of all your work.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 14/53
Getting Help in MS Access 2007
• To get help in Access
2007,
look
for
the
help
icon [ ] in the top
right‐hand corner of the
screen and
click
on
it.
• You will be presented
with a window that
looks like
the
one
here
on the right.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 15/53
Getting Started cont’d
Field
Record
Data Type The kind of data
that is stored in this
field.
ViewSelect a type of
view for the table
When you first create a
new database, you will
start off in the Datasheet
View of a new table
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 16/53
Saving Your Table
Switching to
Design
View
• To save our table,
– Click on the Office Button and select Save
– Save the table as “Students”
• Switch into the Design View:
– Click on the View
Button
and
select
Design View
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 17/53
Data TypesBefore we add fields to our table, let’s learn a little bit about the different types of data.
•Text: Short text (up to 255 characters)
•Memo: Lengthy text
(up
to
65,636
characters)
•Number: Numbers can have different sizes that can
store larger or smaller numbers. Take a look at
the bottom
left
of
the
window
screen
for
the
tab called “General”. Click on the “Field Size”
option and scroll down to view the different
number types
that
you
can
use.
For
example:
Integer: ‐32,768 to 32,767 (no decimals)
Decimal: Includes 28 decimal points.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 18/53
More Data Types
• Date/Time: Date & time values for the years 100 to
9999
• Currency: Currency values (includes 4 decimal places)
• Yes/No: A true
or
false
value
(i.e.,
a boolean value)
• AutoNumber: A unique number (sequential or random)
that MS
Access
assigns
to
every
new
record.
• There are a few others that you can look at yourself.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 19/53
Adding Fields to the Table in Design View
• Create the following fields:
– Student ID ( AutoNumber, increment )
– Name (text )
– Age (number )
–
Enroll Date
(date/time short
date*)
– City (text )
Right-click on
the “Student ID”
field and select
“Primary Key”
* See the ne xt
slide for how to do this!
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 20/53
Date / Time Fields
• On the previous slide, we had a
Date
/
Time
field
as
the
4th
field
in our table. We want the
format of that enroll date to be
a “short date”.
• To do this…
– Click on “Enroll Date” field
– Now click on “Format” and…
– Select “Short Date” from the list
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 21/53
Primary Keys
• A Primary Key is a value that uniquely identifies each
record in a table (ex. Student ID).
• In the table that we just created the Primary Key is
the first
field
in
the
table
(Originally
named
“ID”,
we
have since renamed it to “Student ID”).
• This means
that
for
each
new
record
MS
Access
will
automatically create a unique number for the
Primary
Key
(in
this
case,
Student
ID).
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 22/53
Datasheet View
• Save the table
– Click on the Office Button
– Select Save
•
Switch into
the
Datasheet
view:
– Click on the View Button
– Select Datasheet View
• This is
the
Datasheet
view.
It
allows
you
to
see
the
data that is currently in the table
– (in this case none, because we just made the table).
• Create 5 different records for our table. – Notice how the AutoNumber field fills itself in.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 23/53
Datasheet View cont’d
•
Here
is
some
sample
data
for
the
“Students"
table:
Make sure to save your table once you’ve
finished entering
all
the
data
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 24/53
Creating a 2nd Table
• Create a new table
– Go to the Create tab
– Select
Table
– *Make sure you are in Design View
•
In
Design
View,
add
the
following
fields: – City (text )
– Country (text )
– Population (number long integer )
Right-click on the“City” field and select
“Primary Key”
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 25/53
Entering Data to the 2nd Table
• Save this table as “Cities” and enter the Datasheet view.
• Create 5 different records for the 2nd table and save.
Make sure that the cities that appeared on our first table
(Students) appear on this table as well.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 26/53
Table Relationships
• A relationship in a database is a logical link between
two tables.
• For example,
in
our
1st table,
“Students”,
we
have
a
field called “City” that also appears in our 2nd table, “Cities”.
• This is
a common
field.
• It stands to reason, then, that if we know a particular student’s hometown city (taken from the “Students”table), then we should be able to access the
corresponding information about that city located in
the “Cities” Table (assuming there’s a record
representing that
particular
city).
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 27/53
Table Relationships cont’d
• When viewing a table, go to the Datasheet tab (not datasheet view ) and select Relationships
• A list
of
all
Tables
and
Queries
pops
up.
– Double‐click on “Students” & on “Cities”
– Click “Close”
• This screen displays relationships
between the tables .
•
Click and
hold
onto
the
“City ” field
in
the
“Students”
table and then drag it onto the “City” field in the
“Cities” table.
•A
window
will
pop
up
on
screen
that
looks
like
this...
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 28/53
Relationship Line
“City” is the Common Field.
Click on “Create” ….
… & remember to SAVE!
Table Relationships cont’d
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 29/53
Queries
• What’s a Query?
– Queries are questions
– A
Query
selects
a subset
of
data
from
one
or
more
tables
based on criteria that you give it.
• Now that we have two linked tables we can create
some queries
to
retrieve
data
from
the
tables.
• There are 6 kinds of queries: Select , Update, Insert , Make‐Table, Crosstab, and Delete.
– For this
class
we
will
only
cover
Select queries.
• A Select query retrieves data from one or more
tables, but doesn’t change anything.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 30/53
Query Example
• Click on the Create tab and select Query Design
• Add the “Students” and “Cities” tables
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 31/53
Query Example cont’d
• Now drag the fields that you want to
include in
your
query
to
the
bottom
section
of the screen.
• For our example, add
the “ Student ID” field
and the
“Name” field
from the “Students”table.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 32/53
Query Example cont’d
• Save the query as “Query1”.
• Switch to Datasheet View
• View the results of the query.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 33/53
Adding A Criteria to our Query
• We will now add a
criteria to
the
“Student ID” field.
• Add a criteria (such as >2 for Student ID)
• Save the query
• Switch to Datasheet View
• Note that only students who have a Student ID
greater than
2 are
displayed.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 34/53
Query – User Input
• Sometimes you want to be able to change the criteria of a
query.
– For example, we want to allow the user to only view information for a
particular student
that
they
specify
– As well, we want to allow the user to specify any particular student by
typing in his or her name
•
To
do
this
we
use Square
Brackets:
[
]• Switch back to the Design View and…
– Delete the “>2” criteria for Student ID field
– Add “[Enter Name]” as the criteria for the Name field and SAVE
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 35/53
Query – User Input cont’d
• Switch to Datasheet View
• Enter the
name
of
one
of
the
students
and click OK
• Note that the text inside the square
brackets [Enter
Name]
is
the
text
that’s being displayed
• Also note that only that particular student and his or her ID # is
being shown.
• This is because the query only returns the information for the particular
student that
the
user
specified.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 36/53
Queries – Linking Tables• Switch to Design View
• Don’t forget to delete the criteria from the previous example
•
Add
the
“City” and
“Population” fields
from
the
“Cities” table
to
the query by dragging them down
• SAVE and view the results by switching to the Datasheet View.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 37/53
More than Criteria
• You can have more than one specified criteria in a query!
• To illustrate, switch back to Design View
• Set the criteria for Student ID field to >2 and…
• Set the criteria for the Population field to >=100000
•SAVE and
switch
to
the
Datasheet
View
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 38/53
More than Criteria cont’d
• Compare these
results with
query example
we
did
where
the
only criteria was
for student ID
(>2).
• Notice the
difference?
OLD
NEW
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 39/53
as Criteria
• Text can also be used as suitable criteria
• Switch back
to
Design
View
• Delete the two criteria from the previous example and…
• Set the criteria for City field to Like “Toronto”
• SAVE and switch to the Datasheet View
Note how only the information regarding Guelph is displayed
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 40/53
as Criteria cont’d
• We can also use the wildcard character ‘*’ as part of the text
•Switch
back
to
Design
View
• Change the criteria for City field from: Like “Toronto”
to: Like “To*”
• SAVE and switch to the Datasheet View
Note how the result is the same! This is because the wildcard
character
‘*’ substitutes
for
any
and
all
possible
combinations.
l d
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 41/53
Logical Operators used in Criteria
• When we talk about logical operators, we’re
referring to the operations of:
‘AND’ ‘OR’
• The ‘AND’ operator can be used to create a criteria
that
must
satisfy
2
or
more
conditions.• For example, we could list all birthdays between
August 3rd, 1981 & May 25th, 1983 by using the
following criteria:
>=8/3/1981 And <=5/25/1983
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 42/53
Logical Operators
used
in
Criteria cont’d
• The ‘OR’ operator can be used to create a criteria
that must
satisfy
at
least
1 of 2 (or
more)
conditions.
• For example, we could list all the people named John
and all people named Christina by using the following
criteria:
“John” Or “Christina”
• Let’s do an example…
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 43/53
Logical Operators used in Criteria cont’d
• Switch back to Design View
• Delete the old criteria from the previous example and…
• Set the criteria for Population field to >10,000 And <100,000
• SAVE andtake a look at
the results in
Datasheet
View.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 44/53
Logical Operators used in Criteria cont’d
• Switch back to Design View
• Slightly modify the criteria from the previous example by…
• …setting the
criteria
for
Population field
to
<10,000
Or
>100,000
• SAVE andtake a look at
the results in
Datasheet
View.
Q S ti
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 45/53
Query ‐ Sorting
• Switch back to Design View
• Delete the criteria from the previous example.
• We are now going to sort the output of the query so
that it displays in ascending order according to Name
•
SAVE and
take
a
look
at
the
results in Datasheet View.
Note that
we
can
sort
the
query’s output in either ascending or descending order according to any of the fields.
Query Showing Relevant Fields
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 46/53
Query – Showing Relevant Fields
• Just because a particular field is included in a
query, doesn’t
mean
that
you
have
to
display
that
field when the query performs its function.
• For example, we’re going to modify our query so
that the
“Name” field
is
not
being
displayed
in
the
Datasheet View.
• Note we want to make sure that even though
“Name” is not
being
displayed,
we
still
want
the
query to sort in ascending order according to the
“Name” field.
Relevant Fields ’
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 47/53
Relevant Fields cont’d
• Switch back to Design View
•
Remove the
checkmark
for
“Show” under
the
“Name” field.
• SAVE and take a
look at the results
in Datasheet
View.
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 48/53
Relationship Importance t’d
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 49/53
☺
Relationship Importance cont’d
Relational Databases
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 50/53
Relational Databases
• This brings us to the idea of a relational database.
• A relational database is a type of database that stores information in tables that are related to
each
other
through
common
fields.• This is extremely useful because it allows us to
organize our data visually in a kind of Concept Map
that can
make
our
database
easier
to
understand.
• As well, having our information divided up into
different, but related, tables, lets us view the
information in
any
number
of
different
ways.
Introduction to Functions
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 51/53
Introduction to Functions
• Functions can be used in queries.
• For example,
we’re
going
to
use
the
AVG
function to determine the average
population
of
the
5
cities
in
the
“Cities” table.
• Create a new query in Design View.
• Add the
“Cities” table.
• Add the “Population” field.
• Now, save
the
query
as
“Average
Population”
Introduction to Functions cont’d
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 52/53
Introduction to Functions cont’d
• Click on the Totals button
– This can
be
found
on
the
Design tab
• This will cause a new row called “Total”
to show up in the query design area.
• Click and
scroll
down
to
find
the “Avg” function.
• SAVE & switch into the Datasheet View
That’s all for this tutorial!
8/8/2019 Access 2007 Tutorial 1
http://slidepdf.com/reader/full/access-2007-tutorial-1 53/53
That s all for this tutorial!
• As usual, if you have questions come to one
of the
Zoe’s or
one
of
the
TA’s
office
hours
or post your ‘query’ (hehe, get it? query?) to
the online
conferences.
•Next
Access
Tutorial:
– Functions and Forms and Reports (oh my!)