Professional Documents
Culture Documents
Chap14 1473751047 598112
Chap14 1473751047 598112
Databases
Objectives
After studying this chapter, the student should be able to:
Define a database and a database management system (DBMS) and describe
the components of a DBMS.
Describe the architecture of a DBMS based on the ANSI/SPARC definition.
Define the three traditional database models: hierarchical, networking, and
relational.
Describe the relational model and relations.
Understand operations on a relational database based on commands
available
in SQL.
Describe the steps in database design.
Define ERM and E-R diagrams and explain the entities and relationships in
this model.
Define the hierarchical levels of normalization and understand the rationale
for normalizing the relations.
List database types other than the relational model.
14-1 INTRODUCTION
Data storage traditionally used individual, unrelated
files, sometimes called flat files. In the past, each
application program in an organization used its own file.
In a university, for example, each department might
have its own set of files: the record office kept a file
about the student information and their grades, the
scheduling office kept the name of the professors and
the courses they were teaching, the payroll department
kept its own file about the whole staff and so on. Today,
however, all of these flat files can be combined in a
single entity, the database for the whole university.
14.1.1 Definition
Although it is difficult to give a universally agreed definition
of a database, we use the following common definition:
Less redundancy
In a flat-file system there is a lot of redundancy. For
example, in the flat file system for a university, the names of
professors and students are stored in more than one file.
Inconsistency avoidance
If the same piece of information is stored in more than one
place, then any changes in the data need to occur in all places
that data is stored.
Efficiency
A database is usually more efficient that a flat file system,
because a piece of information is stored in fewer locations.
Data integrity
In a database system it is easier to maintain data integrity
(see Chapter 16) because a piece of data is stored in fewer
locations.
Confidentiality
It is easier to maintain the confidentiality of the information
if the storage of data is centralized in one location.
14.1.3 DATABASE MANAGEMENT SYSTEMS
A database management system (DBMS) defines,
creates, and maintains a database. The DBMS also
allows controlled access to data in the database. A
DBMS is a combination of five components: hardware,
software, data, users, and procedures (Figure 14.1).
Software
The software is the actual program that allows users to
access, maintain, and update data. In addition, the software
controls which user can access which parts of the data in the
database.
Confidentiality
The data in a database is stored physically on the storage
devices. In a database, data is a separate entity from the
software that accesses it.
Users
The term users in a DBMS has a broad meaning. We can
divide users into two categories: end users and application
programs.
Procedures
The last component of a DBMS is a set of procedures or
rules that should be clearly defined and followed by the users
of the database.
14-3 DATABASE ARCHITECTURE
The American National Standards Institute/Standards
Planning and Requirements Committee (ANSI/SPARC)
has established a three-level architecture for a DBMS:
internal, conceptual, and external (Figure 14.2).
Figure 14.2 Database architecture
14.2.1 Internal level
The internal level determines where data is actually stored
on the storage devices. This level deals with low-level access
methods and how bytes are transferred to and from storage
devices. In other words, the internal level interacts directly
with the hardware.
14.2.2 Conceptual level
The conceptual level defines the logical view of the data.
The data model is defined on this level, and the main
functions of the DBMS, such as queries, are also on this
level. The DBMS changes the internal view of data to the
external view that users need to see. The conceptual level is
an intermediary and frees users from dealing with the
internal level.
14.2.3 External level
The external level interacts directly with the user (end users
or application programs). It changes the data coming from
the conceptual level to a format and view that is familiar to
the users.
14-4 DATABASE MODELS
A database model defines the logical design of data. The
model also describes the relationships between different
parts of the data. In the history of database design, three
models have been in use: the hierarchical model, the
network model, and the relational model.
14.3.1 Hierarchical database model
In the hierarchical model, data is organized as an inverted
tree. Each entity has only one parent but can have several
children. At the top of the hierarchy, there is one entity,
which is called the root.
There are two relationship sets in Figure 14.16, teaches and takes,
each connected to two entity sets. The relations for these
relationship sets are added to the previous relations for the entity
set and shown in Figure 14.18.
XML
The query language normally used for objected-oriented
databases is XML (Extensible Markup Language). As we
discussed in Chapter 6, XML was originally designed to add
markup information to text documents, but it has also found
its application as a query language in databases. XML can
represent data with nested structure.