Professional Documents
Culture Documents
In this lesson, we will discuss what a database does and how to decide whether you need a database to manage your
information.
What is a database?
A database allows you to store information related to a specific topic in an organized way. In addition to storing data, you
can sort, extract, and summarize information related to the data. One of the software programs that allow you to do this
is Microsoft Office Access, which is a database creation and management program.
You could use Microsoft Excel to store and manage this type of data; however, Excel is a spreadsheet software program
that is traditionally used to manage numerical information, like totaling up all purchases by one customer. While it can
do an adequate job of storing some types of text-based data—like a customer's name and contact information—that is
not really what Excel was designed to do.
The following examples will show you why an Access database may be a better choice for the bookstore business.
Excel example: Customer list and order tracking
However, if you want to see very specific results in your data, like how many orders
a single customer placed in a year, Excel is not as efficient as Access at providing
you with that data.
As you can see in the image above, customers Tonya Bullock and McKenzie Grant each placed several orders on different
days and for different books. Their customer contact information was entered every time they placed an order. This is the
limitation of spreadsheet software such as Excel because it is a single, flat file.
Access example: Customers and orders tracking
In addition to the table with customer information, you would probably also want a table with information about the
products you sell, and a third table to hold data related to specific customer orders. These tables would be linked
together to help you make the most out of your data.
Access is called a relational database management program because the tables are linked, or related, as you can see in
the image below.
In this example, the Customer Info and Orders tables are linked by Customer ID and Book ID.
Now, let's assume that you want to identify the book that was most popular in the state of North Carolina. With Access,
this is possible because you can search and retrieve information from multiple tables at the same time.
Introduction
Once you have determined that an Access database will help you store and manage your data, you will need to learn
the parts of a database, how to start using Access, and how to navigate the Access window. In this lesson, we will
provide a basic overview of Access, including the parts of a database and common tasks you can complete using a
database.
Exploring databases
Databases in our lives
Think about all of the information we encounter on a typical
day that might be organized by a database. For example, if
you go shopping at a department store for a toaster,
the store inventory of products is information that has to
be stored somewhere, along with the price of each
product.
Think about it
Think about what is going on around you in everyday situations and whether there might be a database at work.
Grocery store: The grocery store is stocked with items. Items must be ordered, shipped, and stocked in the store. The
store has to pay for the items. Then, when a customer buys the items, the cash register retrieves prices, and the
customer pays for products. Where might databases be involved in the situation?
Restaurant: Where does the food come from? How does management know when to reorder a product? How are bills
paid?
Traffic lights: Who or what controls when the lights turn red or green?
A database maintains order and structure in our lives. Databases are created using programs such as Microsoft Office
Access ,, which is a relational database program.
Getting started with Access
When you start Access, you will see the Getting Started window.
In the left pane, the template categories—including the featured local
templates—are listed, as well as the categories on Office Online.
Templates are prebuilt databases focused on a specific task that you can
download and use immediately.
Opening a database
You have three main options on the Getting Started page. You can open a template database stored locally or online, an
existing database, or a blank database.
The Ribbon
Like other software in the Microsoft Office, suite, Access, has a tabbed Ribbon system that you use to navigate the
database. The Ribbon is organized into tabs. Each tab contains groups of commands that you use to perform tasks in
Access.
Navigation Pane
The main control center of each Access database is the Navigation Pane. It shows you
what is in the database and makes the information accessible to you. You can choose to close the
Navigation Pane if you need more of the Access window to complete specific tasks .
Parts of a database
A Microsoft Access database is made up of several components, including tables, forms, queries, and reports. These
components are called database objects. One or more of these objects is formed when a database is created, and all of
the objects appear in the Navigation Pane. To make the database easier to navigate, beginning Access users may want to
reorder the objects in the Navigation Pane.
We'll look at each of these objects in more detail in later lessons, but you can access them from the Navigation Pane like
you can with tables.
1. Tables
A table is the database object that contains the basic information you wish to store. A blue
and white icon represents the table in the Navigation Pane.
In the Customer Info table below, there are columns, or fields, of information, including
title and author. Each row is a record that contains the information specific to the fields
listed.
2. Queries
Another database object is called a query. A query allows you to retrieve information from one or more tables based on
a set of search conditions you define using the table fields.
For example, if you want to know the name of the books that have sold in Colorado and Kansas, you could create a query
that would retrieve information from multiple tables to determine the answer. In this example, you would retrieve
information from the Order table and Books table. Queries are covered in more detail in later lessons.
3. Forms
A third database object is the form. Forms are an Access tool that users can create to make data entry in database
tables easier.
Entering data directly into a table can be difficult if there is a lot of information to enter. Like an Excel spreadsheet, an
Access table is essentially a screen filled with blank rows where a user enters records. Forms, however, provide users
with an easy-to-read interface where they can enter table data. Forms are especially useful for Access users who aren't
comfortable working with databases.
4. Reports
The final database object is the report. A report is an effective way to analyze and present data using a specific layout.
The text can be formatted in an Access report, just like it can be in Word documents.
In this lesson, we'll walk you through the steps of database design using a bookstore scenario. You will determine the
purpose of the database and plan the tables and fields you will need for a simple bookstore database.
Designing a Database
The Ready-2-Read bookstore scenario
The best way to learn about designing a database is to jump right in to the
process. Let's pretend we work for the Ready-2-Read bookstore, and we need to
build a database for the store to use. Let's think about what we might need the
database to do for us.
The following diagram shows that we have customers and
sell books via orders, both in the store and online.
TIP: Keep your database usable to others by giving your tables simple, easy-to-understand names.
We will also need several fields in the Books table. Title and Author make sense for books. We'll need
a Price for each book. Category will help us know what type of books sell the best so we can order
more books that fit into that category.
The Orders table will have fewer fields. We'll need this table to track the Customer who is placing the
order, the Bookthe customer is ordering, and the Date the order is placed.
Don't worry if your plan doesn't include every possible field you may need. Access lets you add fields to tables any time
you think you need another one!
Challenge! Imagine you want to use a database at your new coffee shop. Plan your database:
What would you want to track with your database?
What database tables would you need?
What fields will be in each database table?
Setting up tables
The new database opens with one table showing as a default. It also
defaults to naming this table Table1 in both the Navigation Pane and
the Table tab itself. You will want to name your tables based on your
database design plan.
Naming a table
To give the table a unique name, you must first click on the Microsoft Office Button in
the upper-left corner of the application.
Then, select Save from the menu. The Save As dialog box will appear to let you save the
table whatever name you choose.
To rename a table
With the table closed, right click on the Table you wish to rename in the Navigation Pane.
Select the Rename option that appears in the menu.
The table name will be highlighted and a cursor will appear, which means you can now type in
the new name right there. Left click anywhere outside of the Table name to make the change.
To close a table
There are several ways to close an active table. You can right click on the Table tab and
choose Close from the menu.
To open a table
To open a table, right click the Table name of the table you wish to open in the Navigation
Pane. Next, choose Open from the menu.
A more common method is to double-click the table name in the Navigation Pane. The selected
table will open in the active database object window.
Then, select Table from the Tables command group. A new table will open in the active
database object window. You must name your table using the Save command
from Microsoft Office menu. Naming a Table was addressed on page 3 of this lesson.
TIP: You can tell which table you are currently in by seeing which table tab is highlighted.
Adding fields to a table
Access, allows you to add fields to tables when you are:
Working in Datasheet View, which looks like a spreadsheet
Working in Design View, where you are able to set more controls for your fields
Either way, you need to know how to switch between the two views.
Switching views
To switch views, select the Views command group from either the Home tab
(see below) or the Datasheet tab on the Ribbon. Select the view option you
would like from the menu.
The Add New Field text will disappear from the header. Name the field by
typing the name directly into the header. Press the tab key on your keyboard
to move to the next field.
In Design View, you have many field property options you can set to ensure that data can only be entered in certain
formats. Setting these options is a good idea if you want to make sure the data you have in your database is good, strong
data.
Moving fields
If you want to rearrange the order in which your fields appear in a table, Access , lets you easily move them around. To
move a field in Datasheet View, drag and drop the field to the location you want. To do this:
Click on the field header for the field you wish to move.
Move the mouse in the area of the header.
When the cross with arrows appears, hold down your left mouse button.
With the left mouse button still held down, move the cursor to where you would like the field to appear.
Release the mouse button, and the field appears in its new location.
Deleting fields
To delete a field in Datasheet View, just click on the field header, then select Delete from the Field & Column command
group. This is found on the Datasheet tab on the Ribbon.
WARNING: You should not delete any field in a table without first knowing what impact the deletion may have on the
rest of the database!
In Design View
To change the data type in Design View, click the
field name, then press the tab key on your
keyboard. From the drop-down menu under
the Data Type column, select the format you want.
Challenge!
Open Access and build your own database:
Give Table1 a new name.
Add a new table.
Add fields to a table.
Set the data type for a field in a table.
Open and close the tables.
Move a field in a table.
Delete a field in a table.
Building Table Relationships
By now, you have set up the tables you need for your database and created fields for those different
tables. Relationships provide Access with the means to bring that information together for you when you need it.
This lesson explains how to establish relationships between the tables in an Access database. You will learn how to read
and manipulate the relationship map. You will also learn about primary and foreign keys, relationship types,
and referential integrity.
You should now see a relationship map that contains all of the tables that were selected.
Relating tables
There are a few ways to establish relationships between tables:
Using the Edit Relationships command located on the Design tab of the Ribbon
Using the Drag and Drop method
Both methods give you the same end result, but the Drag and Drop method is much easier and saves you several steps.
2. Drag the field name from the one table to the other table in the desired relationship.
3. Drop the first field name onto the field name you want to relate by releasing the left mouse button.
In the example above, we selected the Book ID field from the Books table and dragged and dropped it on
theBook ID field in the Orders table.
4. The Edit Relationships dialog box appears.
Challenge!
If you haven't already done so, save the sample Ready2Read database on your own computer.
1. Open the database, and establish a relationship between the Books table and the Orders table using the Drag
and Drop method.
2. Establish a relationship between the Customers table and the Orders table using the Edit Relationships command
on the Ribbon.
3. Edit an established relationship by double-clicking the link.
4. Explore the options and settings in the Edit Relationships dialog box.
5. Move the tables around in the relationship map.
1. Click the cell containing the information that must be edited. A pencil
icon appears to indicate edit mode.
Data validation
Data validation is a very important database concept. It is the process by which Access tests the data that is being
entered into the database to make sure it is in an acceptable, or valid, format.
Imagine one of your database users has entered an order date of January 4, 2008, in the month/date/year format as
01/04/2008. Another user has entered an order placed on that same date in the day/month/year format as 04/01/2008.
If the database is tracking all sales for the month of January 2008, it may not show both orders as placed in January, even
though both were placed on the same date.
Access allows you to set field properties and data validation rules to force the person entering data to follow a specific
format.
Validation text
Validation text is a specialized error message that you can set to have Access tell the person entering data the specific
way you would like that person to enter it.
To set the Validation text, enter the error message exactly as you want it to appear to your user in the row directly
beneath the Validation Rule row in the Field Properties section of Design View. For the validation rule that we set for
Category, you would set the validation text like this:
The following image shows the resulting error message that the user would
see when the Category validation rule has been broken:
An Access form also lets you know exactly what information to enter
and can even tell you what that information should look like. Adding
certain control components to a form—like a drop-down menu—can
dramatically increase the integrity of the data that is held in a database.
A database owner wants to control the levels of access other database users have to the data; the fewer the amount of
people who are interacting with the data, the lower the chances are of the data becoming compromised. Forms are one
more way a database owner can limit the actions of the other users. Form properties can be set so users can only enter
records or just view records.
Creating a form
Access has several automatic tools for creating forms. These tools are located in the Forms group on the Create tab in
the Ribbon, as seen below:
Your data must be entered using an acceptable format. The acceptable formats were established when the field
properties were set.
Save by using either the Save command on the Ribbon or by progressing to another record using the New (Blank)
Record navigation button. Moving to a new record saves the most recently entered record. However, it may be necessary
to refresh the table in Datasheet View to see the newest record.
Sorting Records
Sorting is probably the simplest way to look at data because it keeps similar things together. In our bookstore database,
for example, we could sort our data a number of ways:
We could sort orders based on the order date.
We could sort customers by the state in which they live, or by their zip codes.
We could sort our books by author, category, or price.
Access allows you to sort the records in your database tables based on a field or value that is either text (like an author's
last name) or numerical (like a customer's zip code or a book's price). Depending on the type of value, Access offers
different sorting options.
To clear a sort
To clear your sort:
Click the Clear Sort command in the Sort & Filter group on the Ribbon.
Using Queries to Make Data Meaningful - Part 1
The real power of an Access database lies in the ability to pull data for quick analysis, which is what happens when you
run a query. Queries allow you to retrieve information from one or more tables based on a set of search conditions you
define. Access will display your results in their own table that you can analyze and manipulate further. This lesson will
explain how to plan a query using a three-question planning process. You will learn how to use the Query
Design command to run the query, as well as how to modify the query to hide fields or other information in your query
results. Finally, it will show you how to save the query for later use.
Using queries
Queries retrieve information from one or more tables based on a set of search conditions you set up and then combine
that information in a way that is easy for you to analyze. If you have used an Advanced Filter in Access, then you have
already run a very basic query on only one table. If you want to pull data from more than one table, though, you will need
to use either the Query Design command or the Query Wizard.
Before using the Access query tools, it is important to plan out the query using a logical process. Otherwise, you may not
get the results you expect.
Planning a query
There are three questions you need to answer when you are planning a query:
What do you want the results to look like? Identify every field or bit of information that you want included in the
results.
Where is the information stored in the database? List which tables (and/or queries) hold the information you
want to see.
What conditions do you want the data to meet? This helps determine how to set the criteria so Access can
search the records properly.
What fields do we want to see in the results? We need a list of customer names and addresses in
order to mail the coupons to our customers, so we'll need the results to show:
What is the condition we want the data to meet? We want Access to look for only the books where
the book's category is technology.
3. Drag and drop the fields you want to see in your results to the bottom portion of the query design screen.
4. Enter the condition in the Criteria row for the condition field. For our query, we typed Technology in the cell
labeled Criteria for the Category field. As seen above, Access , puts quotation marks around the term to show
that it is looking for exactly that term within the designated field.
5. Once the condition is set, click Run! in the Results group on the Ribbon.
6. Finally, view your results to determine if they match your desired results.
Hiding fields or other information in the results
Sometimes the results of a query will include information that is seemingly unnecessary to you. Access , allows you to
easily hide these fields.
2. When you run your results, that field will be hidden, as seen below.
To save a query
To save the query for later use:
1. Right-click on the query tab.
2. When the Save As dialog box opens, give your query a meaningful name.
3. Click OK.
4. The query will now be listed in the object list on the left side of the Access window.
Using totals in a query
Sometimes you may want to see your query results grouped or counted in some way. Access , offers several options to
make these functions possible. Perhaps the easiest of these is the Totals command, whose optional functions are similar
to the functions used in Microsoft Excel.
These functions include:
Sum, which is used to add a column of numbers
Average, which is used to find the average of a column of numbers
Maximum, which returns the highest value in a field
Minimum, which returns the lowest value in a field
Count, which is used to count the number of same values in a query
One of the most useful Totals functions to use in queries is the Count function.
Notice that we get a record back for every order of each book that has been ordered.
In our bookstore example query, we want to see these titles grouped together so we see each ordered title only one
time. To do this, we use the Count and Group By options.
The Total row will instantly appear in the bottom portion of the query design screen.
2. Click in the Totals row for the field you wish to count. We want to count the number of times the same Book
IDappears in the Orders table.
3. From the list of optional Totals functions, select Count.
4. Click Run! to see your results. Notice that each title, author, price, and category is now listed only one time for
each book, with an extra column that indicates the number of times the Book ID appeared in the Orders table.
As you know, queries make the data in a database meaningful to you. Sometimes, though, you need to share that data
with someone else. A report is an effective way to present your data using an attractive layout. The text can be formatted
in an Access report like it can be done in Word documents.
Access , offers tools that allow you to create and format a report. The Report Wizard walks you through the steps of
creating a report. The Report command, however, is much easier to use, and all of the formatting options are still
available to you in Layout View once the report is created. With these tools, you can create a report based on a table or
query.
The layout and formatting of the report can be manipulated in Layout View.
Creating a report based on a query
Access , can also create a report using a query as the source. The process for creating a report based on a query is
identical to the process for creating a report based on a table, which was outlined on the previous page. And just like
when making a report from a table, every field and record that appears in the query results will appear on the report.
3. Click Run! to make sure the query results look like you want the report to look.
4. Create the report using the Report command on the Create tab.
5. Format the report as desired.
Formatting a report in Layout View: Access opens the created report in Layout View so you can easily make
modifications. In Layout View, you can change the look of your report in many different ways, including:
Deleting columns and other report elements
Moving and resizing columns
Adding a logo
Changing the title and other text on the report headings
Applying a report style with AutoFormat
Modifying the page layout
To delete a column or other report element: To delete a column or other report element:
1. Highlight the element by clicking on it.
2. Hit the Delete button on your keyboard.
To move a column or other report element: To move a column or other report element:
1. Highlight the element by clicking on it.
2. Drag and drop the element to a new location on the report.
To resize a column or other report element: To resize a column or other report element:
1. Highlight the element by clicking on it.
2. Drag and drop the edge of the element to the new size on the report.
Saving a report
When you have created and modified a report and try to close it, Access will prompt you to name and save the report. If
you do not need this report again, you do not need to save it. However, if you think you may want to publish it again, it is
best to save.
To save a report: As with all Access objects, to save a report:
1. Right-click on the report tab.
2. Choose Save from the list that appears.
3. When the Save as dialog box opens, give the report a name.
4. Click OK.