Database
-People often need to retrieve specific data rapidly while on the job. For example, a
customer service representative may need to locate a customer’s order status
quickly while the customer is on the telephone.
-The registrar at a university may have to look up a student’s grade point average or
rapidly determine if the student has any outstanding fees before processing his or
her class registration.
-A librarian may need to determine if a particular book is available to check out
and, if not, when it is scheduled to be returned.
-The type of software used for such tasks is a database management system.
Computer-based database management systems are rapidly replacing the paper-
based filing systems that people used in the past to find information.
- The most common type of database used with personal computers today is a
relational database. The basic features and concepts of this type of database
software are discussed next.
What Is a Database?
-A database is a collection of related data that is stored on a
computer and organized in a manner that enables information to
be retrieved as needed.
-A database management system (DBMS)—also called database
software—is the type of program used to create, maintain, and
organize data in a database, as well as to retrieve information
from it.
-Typically data in a database is organized into fields, records, and
files.
- A field (today more commonly called a column) is a single
type of data, such as last name or telephone number, to be
stored in a database.
- A record (today more commonly called a row) is a collection
of related fields— for example, the ID number, name, address,
and major of Phyllis Hoffman (see Figure 1,below).
Paper-based vs. computerized databases.
-Data is organized into fields (columns), records
(rows), and tables.
-A table is a collection of related records (such as all student
address data, all student grade data, or all student schedule
data).
-One or more related tables can be stored in a database file.
-The most commonly used relational database management
systems (RDBMSs) include Microsoft Access and Corel Paradox
(both part of their respective software suites), Oracle Database,
and IBM’s DB2.
-Some of the basic features of relational database programs in
general are described in the next few sections, using Microsoft
Access 2016 as the example.
- Recent versions of Access save database files with the .accdb
extension by default
Typical database objects. Common database objects include
tables, forms, queries, and reports.
-The first object to be created is the table
Creating a Database
-An Access database can contain a variety of objects. Tables are the
objects that contain the database data.
-Other types of objects (such as forms, queries, and reports, discussed
shortly) can be created and used in conjunction with tables when
needed.
As shown in Figure 1 above, a list of the various objects stored in a
database file is displayed when the file is opened.
- However, you do not see the content of a database object until
you open that object.
- To create a database, you create the database file first, and then
you create the database objects you want that database to
contain.
- Each time Access is launched, you have the option of creating a
new blank database file, creating a database file from a template,
or opening an existing database file.
- If you choose to create a new blank database file, a new blank
table opens in the table’s Datasheet view (which displays the table
in rows and columns similar to a spreadsheet—see the left screen in
Figure 3 below)
-As data is entered into a new table using Datasheet view, the structure of the
table (the fields and their properties) is created.
-Each column becomes a new field and is given a temporary field name (a
unique identifying name, such as Field1) and is assigned an appropriate data
type (which identifies the type of data to be contained in the field; for
example, text, a number, or a date) based on the data initially entered into
that field.
-These properties can be changed by selecting the field and using the
commands on the Fields tab on the Table Tools contextual tab on the Ribbon
(such as selecting the Name & Caption option in the Properties group to
rename the field or selecting a different data type using the Data Type option
in the Formatting group).
-Each field should be given a descriptive field name and the data type should
be changed if the default data type is not correct.
-A field can also be declared a required field if it cannot be left blank.
-Other field properties include the field size (the maximum number of characters
allowed for the content of that field), the default value (the initial content of
that field that remains until it is changed), the field description, and the format
(how the field content should be displayed, such as including commas or dollar
signs with numeric data).
-The table’s Design view can also be used to create the table structure
and change field properties.
-When the table is saved, it is given a name by the user and both the table
data and structure are saved in that table object.
-To add new data to an existing table, to edit data, or to delete data,
either a form or the table’s Datasheet view can be used.
-A form (which is created by the user for a particular table, as discussed
more in Chapter 12) typically displays one record at a time, while a table’s
Datasheet view displays several records at one time.
-However, as shown in Figure 4 , either Datasheet view or Form view can be used to
change the data in the table.
-Data can be edited by clicking inside the appropriate field and then making the
necessary edits.
-A record can be deleted in a table’s Datasheet view by clicking to the left of the first
field in the appropriate row and then pressing the Delete key.
-A field can be deleted in a table’s Datasheet view by selecting the appropriate field
(column), and then pressing the Delete key. –The Record buttons at the bottom of the
Form or Datasheet view window can be used to move through the records as needed.
Queries and Reports
-To retrieve information from a database, queries and reports
are used.
-A query is a question, or, in database terms, a request for
specific information from the database.
-Like other database objects, each query object is created
and then saved using an appropriate name as a part of the
database file.
- A query object is associated with a particular table and
contains criteria—specific conditions that must be met in order
for a record (row) to be included in the query results—as well
as instructions regarding which fields (columns) should appear
in the query results.
-For instance, the query shown in Figure 5 below is designed to
retrieve information from the Product table shown in Figure 4.
-The query retrieves all products in that table that have prices less
than $25, and the query results display only the Product Name,
Product Number, and Price fields.
-Whenever the query is opened, only the records meeting the
specified criteria at the time the query is opened are displayed,
and only the specified fields for those records are listed.
-For instance, the query results shown in Figure 5 contain only two records from
the Product table in Figure 4 because only two records in that table contain
products with prices less than $25.
-If a new product priced less than $25 is added to the database, three records
will be displayed the next time the query is opened.
-When a more formal output is required, reports are used.
-Reports can contain page and column headings, as well as a company logo or
other graphics, and can be formatted and customized as desired.
-Reports are associated with a database table or query and can be easily
created using the Report button or Report Wizard button on the Create tab on
the Ribbon.
-Existing reports can be modified using the report’s Design view. Whenever a
report object is opened, the corresponding data is displayed in the specified
location in the report.
-Consequently, just as with queries, reports always display the data contained in
a table at the time the report is generated.
Databases and the Web
-Databases are often used on the Web. Many Web sites use
one or more databases to keep track of inventory; to allow
searching for people, documents, or other information; to
place real-time orders; and so forth.
-For instance, any time you type keywords in a search box on
a search site or hunt for a product on a retail store’s Web site
using its search feature, you are using a Web database.
T. Mkwapatira