Documente Academic
Documente Profesional
Documente Cultură
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:
The answers to these questions determine how you will structure your database.
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.
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.
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.
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
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
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.
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."
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
All of these records fit the condition: Each has either a CITY field equal to "Chapel Hill" OR a "Y"
value under CARD.