chapter07 lecture notes

advertisement
Concepts of Database Management, Fifth Edition
7-1
Chapter 7
DBMS Functions
At a Glance
Table of Contents

Overview

Objectives

Instructor Notes

Quick Quizzes

Key Terms
Lecture Notes
Overview
In this chapter, students learn about the nine functions performed by a database management system. Some of the
functions were introduced in previous chapters and are re-emphasized in this chapter because they are key
components of a DBMS. Students will learn about the following functions: update and retrieve data, provide
catalog services, support concurrent update, recover data, provide security services, provide data integrity, support
data independence, support data replication, provide utility services.
Chapter Objectives

Introduce the functions, or services, provided by a database management system (DBMS).

Describe how a DBMS handles updating and retrieving data.

Examine the catalog feature of a DBMS.

Illustrate the concurrent update problem and describe how a DBMS handles this problem.

Explain the data recovery process in a database environment.

Describe the security services provided by a DBMS.

Examine the data integrity features provided by a DBMS.

Discuss the extent to which a DBMS achieves data independence.

Define and describe data replication.

Present the utility services provided by a DBMS.
Instructor Notes
Update and Retrieve Data
A DBMS must provide users with the ability to update (add, change, delete) and retrieve data in a database. It is
not necessary for the user to be aware of the system's internal structures or the procedures used to manipulate these
structures.
Concepts of Database Management, Fifth Edition
7-2
Provide Catalog Services
A DBMS must store data about the data in a database (metadata) and make this data accessible to users. The
catalog contains crucial information for DBAs and programmers. Discuss the catalog and the questions that should
be addressed when designing and implementing a database. Point out that DBMSs such as Oracle, DB2, and
Sybase often have a catalog called a data dictionary.
Support Concurrent Update
A DBMS must ensure that the database is updated correctly when multiple users update the database at the same
time. Concurrent update occurs when multiple users make updates to the same database at the same time. Be sure
students understand the concept of concurrent update. Ask students if they have experienced problems at school or
at other locations where multiple users could not access the database at the same time or when the shared update
mechanism did not function properly. Discuss some of the potential problems when covering this section so
students can relate to a personal experience.
The Concurrent Update Problem
Spend time discussing the illustration of this problem that is presented in the text.
Avoiding the Lost Update Problem
One way to prevent lost updates is to prohibit concurrent update. Multiple users can access the database at the
same time for retrieval purposes only. Updates are written to a separate file and then the database is updated
periodically (batch processing). This solution does not work in any situation that requires the data in the database
to be current. Use Figure 7.7 to illustrate this approach.
Two-Phase Locking
Locking denies access by other users to data while the DBMS processes one user’s updates to the database.
Figures 7.8 and 7.9 illustrate locking. Because a transaction can require several updates to the database, there
needs to be some mechanism that allows the DBMS to hold locks until it complete all updates in the transaction.
This approach is called two-phase locking. The first phase is the growing phase, in which the DBMS locks more
rows and releases none of the locks. After the DBMS acquires all the locks needed, and has completed all database
updates, the DBMS releases all locks and acquires no new locks. This is known as the shrinking phase. This is one
solution to the lost update problem.
Deadlock
One problem that can occur with locking is deadlock. Deadlock occurs because each user transaction can require
more than one lock. One user may hold a lock that is required by another user while that user has a lock that the
first user needs. One strategy is to let deadlock occur and then have the DBMS detect and break any deadlock.
Locking on PC-Based DBMSs
Mainframe DBMSs offer sophisticated schemes for locking as well as detecting and handling deadlocks. PC-based
DBMs have more limited facilities. Most PC-based DBMSs can provide:
 Programs can lock a table or an individual row with a table, but only one or the other.
 Programs can release any or all of the locks they currently hold
 Programs can inquire whether a given row or table is locked.
Because the capabilities of PC-based DBMSs are limited, programmers must be responsible for writing programs
to handle concurrent update. Guidelines for writing such programs are:
 If an update transaction must lock more than one row in the same table, you must lock the entire table.
 When a program attempts to read a row that is locked, it may wait a short period of time and then try to
read the row again. Include a limit on the number of times a program may attempt to read the row.
 Because there is no facility to detect and handle deadlock, programs must try to prevent deadlock.
 Do not lock rows or tables any longer than necessary.
Concepts of Database Management, Fifth Edition
7-3
Timestamping
With timestamping, the DBMS assigns to each database update the unique time when the update started. The
database processes updates to the database in timestamp order. Timestamping avoids the need to lock rows in the
database and eliminates the processing time needed to apply and release locks and to detect and resolve deadlock.
Quick Quiz
1.
A(n) _____is a set of steps completed by a DBMS to accomplish a single user task.
Answer: transaction
2.
In two-phase locking, there is a growing phase in which all locks are acquired and a _____ phase in which all
locks are released.
Answer: shrinking
3.
An alternative to two-phase locking is a technique known as _____ where the DBMS assigns to each database
update the unique time when the update started.
Answer: timestamping
Recover Data
A DBMS must provide a mechanism for recovering a database in the event that the database is damaged in any
way. Use the embedded questions to test students’ understanding of forward and backward recovery.
Journaling
Journaling is one technique used by large DBMSs to ensure that users do not need to redo their work if a database
is damaged. A journal (log) is a separate file of all updates to the database. The log includes a record of what the
data in a row looked like before the database was updated (before image) and a record of what the data in the row
looked like after the database was updated (after image.) The journal is used in the recovery process to restore the
database. Use Figures 7.10 and 7.11 to illustrate the purpose of a log.
Forward Recovery
If the database does become damaged and needs to be recovered, the after images stored in the log can be used to
bring the database up to date. This recovery technique is called forward recovery.
Backward Recovery
In backward recovery, the before images stored in the log are used to rollback the database to a valid state by
undoing transactions.
Recovery on PC-Based DBMSs
Because PC-based DBMSs generally don’t offer recovery features such as journaling, users periodically should
make backup copies of the database.
Provide Security Services
A DBMS must provide ways to ensure that only authorized users can access the database. The most common
security features used by DBMSs are encryption, authentication, authorizations, and views.
Encryption
Encryption converts the data in a database to a format that’s indecipherable to a word processor or other program.
Authentication
Authentication refers to techniques for identifying the person who is attempting to access the DBMS. The use of
passwords is the most common authentication technique. Biometrics identify users by physical characteristics such
as fingerprints, voiceprints, handwritten signatures, and facial characteristics.
Authorizations
Authorization rules specify which users have what type of access to which data in the database. These
authorization rules also are called permissions. Discuss the use of permissions.
Concepts of Database Management, Fifth Edition
7-4
Views
If a DBMS provides a facility that allows users to have their own views of a database, this facility can be used for
security purposes.
Privacy
An issue related to security is privacy. Privacy refers to the right of individuals to have certain information about
them kept confidential. Spend some time discussing the relationship between security and privacy. This is a good
time to talk about the many ethical issues involved when using a DBMS.
Provide Data Integrity Features
A DBMS must follow rules (integrity constraints) so that it updates data accurately and consistently. Key integrity
constraints are primary key constraints and foreign key constraints. Data integrity constraints help to ensure the
accuracy and consistency of individual field values. Types of data integrity constraints are: data type, legal values,
and format. Integrity constraints can be handled in one of the following ways:
1.
2.
3.
4.
Constraint is ignored.
Responsibility for constraint enforcement is placed on users.
Responsibility for constraint enforcement is placed on programmers.
Responsibility for constraint enforcement is placed on DBMS.
The DBMS should enforce all constraints that it is capable of enforcing; then let application programs enforce any
other constraints. Make sure students understand why it is best to assign the burden of integrity to the DBMS.
Discuss the embedded question.
Support Data Independence
A DBMS must provide facilities to support the independence of programs from the structure of the database. Some
types of changes that may be made to a database structure are: adding a field, changing the length of a field,
creating an index, and adding or changing a relationship.
Adding a Field
If you add a new field to a database, you don’t need to change any program except those programs that use the
new field.
Changing the Length of a Field
Changing the length of a field has no effect on programs except in cases where the field displays in a form or
report and the width allotted to the field is no longer sufficient.
Creating an Index
Adding an index should have no effect on programs. Most DBMSs will use the new index automatically.
Adding or Changing a Relationship
This type of change requires that the database be restructured.
Support Data Replication
A DBMS must manage multiple copies of the same data at multiple locations. Sometimes data should be
duplicated (replicated), at more than one physical location, for performance or other reasons. Replication is a twostep process. Replicas are made, the master and all replicas form a replica set. Then periodically all replicas go
through a process called synchronization that exchanges all updated data between the master and the replicas.
Provide Utility Services
A DBMS must provide services that assist in the general maintenance of the database. A few of the utility services
that a PC-based DBMS may provide are:
Concepts of Database Management, Fifth Edition







7-5
Change the database structure
Add and delete indexes
Use services provided by operating systems while working with the database
Export data to a and import data from other software products
Easy-to-use edit and query capabilities, screen and report generators
Support for procedural and non-procedural languages
Easy-to-use, menu-driven or switchboard-driven interface
Key Terms
All key terms are defined in the Glossary section of the textbook.
after image
authentication
authorization rule
backup
backward recovery
batch processing
before image
biometrics
commit
concurrent update
data dictionary
data independence
database password
deadlock
deadly embrace
decrypting
encryption
forward recovery
growing phase
journal
journaling
locking
log
metadata
nonprocedural language
password
permission
privacy
procedural language
recovery
replica
replicate
rollback
save
shrinking phase
synchronization
timestamp
timestamping
transaction
two-phase locking
user-level security
utility services
victim
workgroup
workgroup information file
Download