You are on page 1of 42

Excel Chapter 12

MANAGING A DATABASE
WITH MICROSOFT EXCEL

Data Versus
Information Versus
Databases
Data are facts about people, objects, events,
transactions, or other entities.
Information includes data that are organized and
presented in a form that supports an
organization's operations and decision making.
The term database describes data that are
organized in a way that makes it easy to find and
update the data, and also provides the ability to
analyze and extract information from the
database.

Using a Database
To Organize Data
A database specifies how separate pieces of data
are related.
In a database, data are related by means of data
structures, which represent associations
between elements of data.
The most basic of these data structures are called
records and fields.

Records and Fields


A record corresponds to a person, object, event, transaction, or
other entity, and is simply a collection of fields.
Each field provides a different piece of information (that is, an
attribute) about the person, object, event, transaction, or other
entity.
For example, in an employee database, each record represents
a specific employee and may contain fields such as an
employee's social security number, last name, first name,
middle initial, department, position, annual salary, and date
hired.
Therefore, at the heart of every database are data structures.
Regardless of what these structures are called, they are logically
equivalent to records and fields.

Representing a Database in
the Form of an Excel List
Microsoft Excel is not a database management
system, nor does Excel provide the power and
sophistication for maintaining a database that are
found in database management systems such as
Microsoft Access or Oracle.
However, many of the features in these database
management systems are common to an Excel
list.
As long as you follow a few simple guidelines, you
can represent a database in Excel in the form of
a list.

An Excel List What Is It?


An Excel list is a rectangular grouping of rows and columns
(i.e., a range) that contain similar data.
A list can be a listing of clients, their addresses, and their phone
numbers, or a list can be a database of employee records,
accounts receivable, or inventory records.
As long as you follow a few simple guidelines, you dont need to
do anything special to the data in an Excel list to make it a
database.
When performing most database tasks - such as adding,
editing, deleting, finding data, sorting, filtering, or generating
summary information - Excel automatically recognizes a list
as a database.

Managing a Database in the


Form of a List

Excel has a number of features that make it easy to


manage and analyze a database in the form of a list.

To take full advantage of these features, design a


database according to guidelines in the following areas:

Database Size and Location

Fields and Names (i.e., column titles)

Entering Data in a Database

Naming a Database

Database Size and Location

Avoid having more than one list or database in a worksheet,


because some list management features, such as filtering, can be
used on only one list or database at a time in a worksheet.

Leave at least one blank column and one blank row between your
database and other data on the worksheet. This helps Excel
automatically select your database when you sort, filter, or insert
automatic subtotals.

For best results, avoid storing other critical data to the left or right of
the database, because it might be hidden when you filter the
database.

A database can be as large as an entire worksheet: 1,048,576 rows


by 16,384 columns. Inasmuch as the first row in a database is used
for field names (i.e., column titles), you can store as many as
1,048,575 records in a single Excel worksheet.

Fields and Names


(i.e., column titles)
1.

Create field names (i.e., column titles) in the first row of your
database. Excel uses these field names to find data, sort data,
filter data, and generate summary information.

2.

If a field name is wider than the data in the column, you can
wrap the text in a cell (i.e., click on the Format button in the
Cells group of the Home tabs Ribbon, choose the Format
Cells command in the Format menu, click on the alignment
tab, and then click on the Wrap text option in the Text control
group).

3.

Use a font, font size, font style, alignment, format, background


color, pattern, border, or capitalization style (e.g., all caps) for
field names that is different from the format you assign to the
data in your database. This enables you to distinguish the field
names from the contents of records.

Fields and Names


(i.e., column titles)
4.

Do not use blank rows or dashed lines to separate field


names from the data.

5.

Separate data into many small fields. This will facilitate


finding, sorting, filtering, and generating summary
information. You can always combine data from two or
more fields for a report.

6.

Use brief, but descriptive field names.

7.

Make each field name unique. For example, use


ADDRESS1 and ADDRESS2 if the database contains
the two address names.

Fields and Names


(i.e., column titles)
8.

Design your fields (i.e., columns) so that each field (i.e.,


column) contains similar data for all records (i.e., rows)
in the database.

9.

Include a field in which the records are consecutively


numbered, such as the Rec # field in the Dept & Salary
worksheet of the Employee workbook. If you
subsequently sort the records in the this database, the
field in which records are consecutively numbered will
enable you to restore the records to their original order.

Dept & Salary Worksheet


in Employee Workbook

Qty & Cost Worksheet


in Inventory Workbook

Entering Data in a Database

Don't insert extra spaces at the beginning of the data you


store in a cell; extra spaces affect finding, sorting, and filtering
records.

Use the same format for all the cells in a column.

You can enter text in a database in either uppercase or


lowercase characters. Excel distinguishes between
uppercase and lowercase characters only when you sort the
data, and then only when you select the Case Sensitive sort
option. Thus, enter the data in the case in which you want to
display and print the data.

You can enter formulas in the cells within a database, just as


you do in any other worksheet cell. When you sort or search
for values in a database, Excel uses the values produced by
the formulas, rather than using the formulas themselves.

Naming a Database

If you will be using the database in a larger worksheet


model, you might want to name it using the Name
Define command from the Insert menu. However, you
don't need to name your database to use any of the
database management features provided by Excel.

If you name your list Database, Microsoft Excel always


designates the first row of the database as column titles
or field names.

One advantage of naming a database is that Excel


automatically updates the range defined by the name
when you add or delete records with a data form.

Database Management Features


with an Excel List

Maintain the database by using a data form to display,


edit, add, or delete one record at a time.
Use a data form to find and display records that match
specified criteria.
Reorganize the data in the database by sorting the
records alphabetically, numerically, or chronologically
according to the contents of a specified field or fields
(i.e., column or columns).
Display a subset of data by filtering the database.
Filtering temporarily hides records (i.e., rows) that don't
meet specified criteria. Thus, filtering allows you to edit,
copy, print, format, subtotal, or create a chart from a
subset of your database.

Database Management Features


with an Excel List

Create summary reports. With Excel, you can


generate summary information, called
automatic subtotals, for selected fields within
groups of data.

Create interactive summary tables, called


PivotTables, which cross-tabulate data in a list
or database.

Generating summary information and


PivotTables are covered in the next chapter.

Using the Data Form

Display one record at a time

Edit one record at a time

Add one record at a time

Delete one record at a time

Find and display records (one at a time) that


match specified criteria.

Dept & Salary Data Form

Qty & Cost Data Form

Adding a Record to
Inventory Database
Field
ITEM NO

Data
101041

DESCRIPTION Table-Mahogany with


marble top
LOCATION

New York

QTY

UNIT COST 3750 or 3,750

Entering a New Record with Data


Form to Qty & Cost Database

Editing a Record in the


Inventory Database
Scroll to record 25 and edit the contents of the
following fields:

Field

Previous
Data

Changed
Data

LOCATION
QTY

Chicago
20

New York
15

Deleting a Record in the


Inventory Database
Scroll to record 30 in the Data Form and delete the
record.
If you click on OK in the warning message dialog
box, Excel renumbers the previous record 31 as
record 30 and displays the contents of its fields in
the data form.
Similarly, the record numbers of the remaining
records are renumbered. Moreover, Excel moves
the renumbered records (formerly records 31 to 33
and now records 30 through 32) up one row in the
worksheet.

Deleting Records with Data Form


Warning Message

Criteria can be a series of characters you want matched in


a text field, such as Carter in a last name field or
Executive in a department field.
If you decide to enter comparison criteria in a number or
date field, you likely will include one of the following
comparison operators for comparing values:
Comparison
Operator
Description
=
Equal
<>
Not equal
>
Greater than
>=
Greater than or equal
<
Less than
<=
Less than or equal

Finding Records with Data Form


and Search Criteria
Field

Criteria

DEPARTMENT sales
SALARY
DATE HIRED

>=30000
>12/31/2002 (use either a
two or four-digit year)

Entering Search Criteria


in the Data Form Dialog Box

Sorting Records with


Sort Dialog Box (Sort Button)
1st Sort Key

Sorting Records with


Sort Dialog Box (Sort Button)
2nd Sort Key

Sorted Dept & Salary


Database Worksheet

Sort Order

Numbers, from the smallest negative number to


the largest positive number; dates and times,
from earliest to latest.
Special characters in following order: ' - (space) !
"#$%&()*,./:;?@[\]^_`{|}~+<=>
Text values, sorting numbers entered as text
first, then character text.
Logical values, FALSE then TRUE
Error values, such as #VALUE! or #NAME?, in
the order in which they are found.
Blank (i.e., empty) cells

FILTERING RECORDS
A major limitation to using the data form to search for and
find records based on comparison criteria is that you can
display and work with only a single record at a time.
However, there may be occasions when you want to display
and work with only those records that match the criteria you
specify.
Because it automatically hides all records (i.e., rows in the
worksheet) except those that match the specified criteria,
Excels Filter easily and quickly enables you to view and
work with only the subset of your database that is of
interest to you.
Just as with the data form, you can specify multiple criteria
for filtering a database.

Using the Filter Button


to Filter Records in a Database
To use the Filter button to filter the records in a database,
complete the following steps:
Select any cell in the database by clicking on it.
Click on the Filter button in the Sort & Filter group of the
Data tabs Ribbon. Excel places drop-down arrows
directly on the right border of the field names in the
database, as shown in Figure 12-15.

Using the Filter Button


to Filter Records in a Database
Click on the arrow on the field that you want to filter by. For
example, click on the down arrow on the DEPARTMENT
field.
Excel displays a drop-down list of all unique items (i.e.,
values) in that field, as shown in the next figure.
Click on Select All to remove the check from that box and
then click on an item in the list, such as Sales, to select it
as the value to filter by.
If you do not see the item you want to filter by, then scroll
down the list. Note, however, that you will see a scroll bar
only if there are more than 9 items in the list.

Using the Filter Button


to Filter Records in a Database
The item you select in a fields drop-down list is called a
filter criterion.
For example, click on Select All
to remove the check from that box
and then click on Sales in the
DEPARTMENT drop-down list.
Excel immediately hides all rows
in the worksheet, except those
17 rows containing the filter criterion
Sales in the DEPARTMENT field,
as shown in the next figure.

Filtering Records
with the Autofilter

Selecting the Custom Filter

Custom AutoFilter Dialog Box


Multiple Criteria in Single Field

Custom AutoFilter Dialog Box


Multiple Criteria in Single Field

Filtered Records

Redisplaying Hidden Records


and Removing the AutoFilter
To display all hidden records in the database,
choose the Filter command from the Data menu
and then choose the Show All command from the
submenu.
To display all hidden records and remove the
AutoFilter arrows, choose the Filter command from
the Data menu and then choose the AutoFilter
command from the submenu.

You might also like