Sunteți pe pagina 1din 10

help.unc.

edu

Database Concepts
Table of Contents
What is a Database? ............................................................................................................................ 1
CommonlyUsedTerms......................................................................................................................1
TypesofDatabases..............................................................................................................................2
What Are the Parts of a Database Program? ....................................................................................... 2
Identifying the Fields to Include ......................................................................................................... 3
DatabaseStructure...............................................................................................................................4
FieldLengths.......................................................................................................................................6
DataStorage........................................................................................................................................6
Relationality: Making Databases Work Intelligently .......................................................................... 7
Data Entry and Display: Forms ........................................................................................................... 7
Organization of Data (Sort Functions) ................................................................................................ 8
Queries and Search Conditions (Report Functions) ............................................................................ 8

What is a Database?
A database is an organized collection of data. The primary function of a database program is to enable
the user to put a collection of information into some specific order: alphabetical, numerical, chronologi-
cal, or some combination of the three. There are two key questions that must be answered before con-
structing a database:

What information do you want to maintain?

In what order do you want this information organized?

The answers to these questions determine how you will structure your database.

Commonly Used Terms


Database Program. The term database is often used to refer to an entire database management system
(DBMS). For example, the software programs Access, dBase, FileMaker Pro, and FoxBase are often re-
ferred to as database programs. Microsoft Excel is usually considered a spreadsheet application contain-
ing several database functions.

Database File. Within a given program, the term database, or database file, has a more specific mean-
ing. It refers to a specific collection of data with a single focus or topic.

Record. A database file is a group of records that are identical in structure. A record contains informa-
tion about a single item in your database.

Field. Each record is made up of a series of fields which store individual bits of information inside a

Copyright 2002, The University of North Carolina at Chapel Hill Academic Technology and Networks. All rights reserved. May
be reproduced in any medium for non-commercial purposes in accordance with the Copyright Policy of The University of North
Carolina at Chapel Hill at http://www.unc.edu/campus/policies/copyright.html.
Database Concepts Page: 2

record.

Types of Databases
There are two main types of databases that you need to know about: flat-file and relational. As the
name implies, a flat-file database consists of a single database file or table which contains all of the in-
formation that you want to store about your topic. This type of database is ideal for a simple database
that does not contain a lot of repeated information. A relational database, on the other hand, consists of
multiple database files or tables linked together by at least one common field. For instance, a library
card catalog might consist of an Author table, a Title table, and a Subject table. This type of structure
eliminates the endless repetition of author and title information that would occur in a flat-file database
containing the same information. In turn, this structure makes data entry easier, as well as easing storage
problems on your hard disk.

What Are the Parts of a Database Program?


In general, all database management programs have the same overall organization. Different types of
objects perform specific tasks. Most database programs contain four main object types: tables, queries,
forms, and reports.

What Are Tables?


Data are always stored in tables, and understanding the design of the tables in your Access database can
save you hours of work. Each table contains information about one subject, such as employees, members
of the class of 1994, or addresses. One table might store customer names and addresses while another
stores customer orders. Tables are made up of records, which contain all of the information about a sin-
gle entry, such as an employee or address. Each record is then subdivided into fields, which are the
smallest increments of useful data in your database. If you are making a mailing list, then you might
have fields for First Name, Middle Name, and Last Name, rather than including only one field for a per-
son's name. Visualize your table by imagining the fields across the top of your table as column headings
and then thinking of each record as a row in the table. Relational databases, like Access and FileMaker
Pro, use many tables that each store different information about a related subject

What Are Queries?


A query is a way of asking questions about data stored in your tables. A query's design tells the database
engine exactly which data to retrieve. With queries you can look at selected data from one or more ta-
bles without viewing all of the fields in each table and without having to save the data over again. The
only parts of a query that most database management programs retain are the design parameters. Queries
are especially useful because they let you organize your data without tampering with the actual records
themselves. For example, you could use a query to alphabetize a mailing list or to select only residents
of Chapel Hill from a state-wide mailing list.

What Are Forms?


Like a paper form, an Access form or a FileMaker Pro layout collects and organizes information. In
Database Concepts Page: 3

forms you can enter data into your database, display this data for review, and print it out. Forms are de-
signed to make on-screen data entry and retrieval easier. In most database programs, you will almost al-
ways use a form to enter and to edit data because you can enter information to be stored in more than
one table on a single form. Another advantage of using forms to enter and to edit data is that you look at
only one record at a time. If you enter data using tables, you will have to look at a confusing number of
records at once.

What Are Reports?


A Report provides a way to retrieve selected stored data and present that information effectively and
meaningfully. Reports are designed to be printed out rather than viewed on a computer screen, so they
need to be carefully planned. Examples of everyday reports include mailing labels, invoices, receipts,
sales summaries, and phone books. You can combine text, data, pictures, lines, boxes, graphs, and draw-
ings to produce exactly the report you want. Fortunately, the latest versions of the big database packages
also come with several pre-planned report layouts that you can set up quickly using Report Wizards.

Identifying the Fields to Include


To create your own phone book database, you need at least three bits of information for each person:
Name, Address, and Phone Number. To make this database more usable, however, you need to further
subdivide this information. The first thing you want to maintain is the name, since that is usually how
listings are ordered in the telephone book. Specifically, entries are ordered first by last name, then by
first name. Each name, therefore, actually consists of two fields: Last Name and First Name. The next
thing you want to maintain is the address, but again, this information consists of smaller units. Tradition-
ally, an address consists of a street number and name (Street), a city name (City), a state abbreviation
(State), and a zip code (Zip): four separate bits of information. Finally, you want to maintain the phone
number. Depending on how detailed you want your database to be, the phone number may consist of a
single field or a set of two fields, one containing the 3-digit area code and the other containing the
7-digit number. If you do not anticipate ever organizing your records by area code (i.e., grouping all
records with the same area codes together), there is no reason to make the phone number two fields.
When creating a database, it is a good rule of thumb to keep the structure as simple as possible. The
more fields in a database, the longer it takes to process and store information. Assuming that you keep
the phone number as a single field, you have now created seven fields out of three bits of information:

At this point, you might choose to maintain additional information for each person, such as birthdate,
Database Concepts Page: 4

whether you send a holiday card, and how many children the person has. This gives you three more
fields for each record:

Now, you need to create a structure for your database using these ten fields.

Database Structure
The structure of a database specifies information about the fields maintained in the records of that
database, including: the name of each field, the type of data maintained in each field, and the required
length (in terms of spaces) of each field. To help clarify this structure, you can use a grid such as this:

Field Names
The field name should be as concise and yet as descriptive as possible. Names should be one or two
words long, and should be some sort of key phrase indicating the type of information to be maintained in
the field. Note the field names used in the phone book example.

Field Types
Generally speaking, database software programs distinguish between different types of information,
handling numbers and dates differently than textual information such as names. The most common field
types are:
Database Concepts Page: 5

Character Fields
Now, looking at the data stored in the first seven fields of your phone book database, you see that all of
them (Last Name, First Name, Street, City, State, Zip, and Phone) should be defined as character fields.
While it is obvious why Last Name, First Name, City, and State are defined as character fields, it may
not be as clear why Street, Zip, and Phone are. Street is a character field because it contains both nu-
meric and alphabetic information (street number and street name). Zip and Phone are defined as charac-
ter fields because although they are used to store numbers, those numbers will never be used in calcula-
tions, i.e., never added, subtracted, multiplied or divided with any other numbers.

Numbers and Field Definition


It is important to be careful in defining a field as either numeric or character when dealing with num-
bers. Once a field is defined as numeric, it can be used in calculations, even if you do not intend for it to
be. For example, if you defined the Zip field as numeric, you would run into problems when you entered
a ten-digit zip code (zip-ext.). For example, in the Zip field, you type: 27599-3480, but when you press
Enter, the Zip field displays instead: 24119. What happened? The program, taking the zip field as nu-
meric, thought a mathematical equation was being entered. It interpreted the dash (-) between 27599 and
34800 as a minus sign and automatically performed a subtraction calculation, then displayed the result in
the field.

Other Fields
The remaining fields (Birthday, Card, and Children) are of different types. Birthday is a date field be-
cause it stores a specific date. Card is a logical field because it asks the yes/no question "Send a holiday
Database Concepts Page: 6

card to this person?" Finally, Children is a numeric field because it stores a number that might be used in
a calculation (e.g., multiply the number of children by $20.00 to calculate amount of check to include in
holiday card). Depending on the database program you use, you may have other field type options, or
you may be able to define a field type at a lower level. For example, some programs allow you to spec-
ify the format in the number field (e.g., whole numbers or decimals; allowable number of decimal
points).

Field Lengths
Most database programs require you to specify the length of each field when you create a database. They
do this to ensure that the stored information takes up no more space than it absolutely has to on your
hard disk, floppy disk, or network device. They also do this to minimize the amount of time it takes for
the computer to process your information. The key is to make each field only as long as its longest pos-
sible entry.

Data Storage
Since database software packages create database structures to store information in the smallest amount
of space possible, you can extrapolate the length of individual records from the total length of all fields.
From this, you can approximate the size of an entire database. Why is this important? Consider the fol-
lowing two examples: 1. At the office, you are assigned to implement a database of approximately 200
clients using the structure you have just created. 2. The University wishes to implement a database of
750,000 alumni using your structure. Where are you going to store this information? Whenever you deal
with memory storage devices like floppy disks, hard disk drives, or network drives, you are automati-
cally dealing with finite resources. These devices will store a certain amount of memory—and no more.
A question you must pose in each example is "Do you have adequate space on your floppy disk/hard
drive/network to store the database you're creating?"

You can approximate the amount of space your database files will occupy on your memory storage de-
vices by multiplying the total of the field lengths by the number of records. The number returned will
approximate the amount of memory space (measured in bytes) required to store the information. For the
first example, you take the number of clients, 200, and multiply that by the total field lengths, 145, to ar-
rive at the number, 29,000. This means that you can expect your client database file to be approximately
29,000 bytes, or over 29 kilobytes (Kb) in length. Should you have trouble fitting this on an empty
floppy disk or on a hard disk? Not really. But in the second example, the number of alumni, 750,000,
multiplied by the total field lengths, 145, returns a value of 108,750,000, for a file size of approximately
109 million bytes, or 109 megabytes (Mb). Can this file be stored on a floppy disk? No. Can it be stored
on a hard drive with a storage capacity of 50 Mb? No. Could it be stored on a hard drive with a capacity
of 125 Mb? Still, probably not: remember, the hard disk has to have room on it not only for the database
file in question, but also for the software package that lets you use it. Also remember the need for expan-
sion: to this alumni database you should expect to add approximately 7,500 records every year. As a rule
of thumb, make sure your memory storage device has available memory of at least 10 times the size of
the projected database, to permit adequate space for backup copies of the database file, along with report
forms and index files that accompany it. The first example would require a floppy disk or hard drive
with at the very least 260 Kb of memory free. The second example should be placed on a hard drive or
network device with around 1 billion bytes, or 1 gigabyte (Gb) of memory, available.
Database Concepts Page: 7

Relationality: Making Databases Work Intelligently


Modern databases must be efficient in order for people to use them in their everyday tasks. The single
largest source of inefficiency in databases is unnecessarily repeated data. A flat-file database will work
just wonderfully for an address book that contains only one address for each person, yet it does not work
so well when several people on your mailing list use more than one address for their correspondence.
You have two options: repeat the data in the same table or build a second table that is related to the first
table by sharing a common field. You might want to break the phone book database file into a Name
database and an Address database. These two tables could then be linked together by sharing a common
field, like Name ID#, in what is called a one-to-many relationship. This type of structure has two pri-
mary advantages: facilitating data entry by removing those unnecessary repetitions and decreasing your
storage needs by no longer needing to store repeated information on your hard disk. Every database
management program provides an easy and intuitive way to create relationships between database files.

Data Entry and Display: Forms


Now that you have a structure in place, you can input data. Most applications display a "blank" record
on the screen: a series of field names, listed vertically, each followed by an empty box, where you can
type in information. Generally speaking, you can enter information into some or all of these fields, and
use the arrow, Tab, or Enter keys to move back and forth between them. Most database software appli-
cations also allow you to customize the display of information on the screen—to change the order in
which the fields are displayed or to give fields different titles on screen (without changing the field
names themselves).

In addition, most database applications give you another way of looking at the data you enter. The above
example allows you to look at the contents of one record only. Most applications also let you browse
through databases, and look at the contents of many records at the same time. For example, in the
spreadsheet-like grid below, the contents of each record appears in a single row, while the columns show
information from the fields.
Database Concepts Page: 8

Organization of Data (Sort Functions)


With this information entered, you can now organize it in a number of ways: alphabetically by last and
first name, geographically by city and state, chronologically by birth date, logically by whether or not
they're on your regular mailing list. You may also need to organize the same information in combina-
tions of these ways: alphabetically by name and by city, or keeping people in the same city together in
alphabetical order by last and first name. In addition, you may need to maintain several orders simulta-
neously, so that you can quickly move from one order to another and back, seeing information displayed
first in one way, and then in another.

Most database applications let you sort the data or create indexes, separate files that arrange the infor-
mation in a database in particular order. Most database applications let you create both single-field in-
dexes (chronologically, by BIRTHDAY, for example) and multiple-field indexes (alphabetically by
CITY, then LAST, then FIRST). In addition, most databases let you create and maintain more than one
index for each database, so that you can quickly shift from one order to another. Indexes order informa-
tion chronologically, numerically, alphabetically, or logically, depending on the fields included in the in-
dex. Our database example, indexed alphabetically by city, would look like this:

Note that the database itself is not changed by using an index. The first record entered in the database re-
mains record number 1. The only thing an index does is change the order in which records are displayed.

Queries and Search Conditions (Report Functions)


Having entered information into the database and organized that information, you now consider ways to
get that information out, usually in the form of reports. Sometimes, you need to print out the all informa-
tion in a database to answer a question like "Who do you have in the database?" Most database applica-
tions allow you to easily print out or display on screen a list of all records in a database. In this way, the
Database Concepts Page: 9

applications enable you to generate customized reports, which display the fields of a database in the or-
der you desire, on forms of your own design. Sometimes, though, you don't need all of that information.
If you need to know only the names and addresses of the people in Chapel Hill to whom you send cards,
you don't want to see the unrelated records and fields. For this reason, most database applications allow
you to select only the fields you are interested in for display. If you wish to see only name and address
fields, then you can select only those fields for display.

In addition, database applications allow you to select single or multiple criteria for database searches. If
you wanted the complete records for all people living in Chapel Hill, you would search on a single crite-
rion: CITY = "Chapel Hill." However, you will often want to define your data set using more than one
criterion or condition. In database applications, you combine multiple conditions with some form of log-
ical connectors—the concepts of "and," "or," and "not."

The AND Logical Connector


In the example above, you are interested in seeing the names and addresses of people in Chapel Hill to
whom you send cards. This search has two conditions: (1) CITY = "Chapel Hill", and (2) CARD =" Y".
If you perform searches of these conditions separately, you get the two separate sets of data. For exam-
ple, your search for records where CITY = "Chapel Hill" results in the following data set.

On the other hand, your search for records where CARD = "Y" results in a different data set.

Neither of these searches alone gives you just the information you need. To accomplish that, you must
connect the two conditions in a third search. If you wish to combine the two searches above to get a list
of people in Chapel Hill to whom you send cards, you must perform a search of the database for records
for which the CITY field equals "Chapel Hill" AND the CARD field has a value of "Y". Such a search
provides you with the following set of data.
Database Concepts Page: 10

The OR Logical Connector


You need to be careful when using these logical connectors in your searches. Using an OR connector in-
stead of AND will give you very different results. For example, a search where the CITY field equals
"Chapel Hill" OR the CARD field has a value of "Y" would generate the following list of ten records, as
opposed to the list shown above which contains only four records.

All of these records fit the condition: Each has either a CITY field equal to "Chapel Hill" OR a "Y"
value under CARD.

S-ar putea să vă placă și