Typically, a DBMS provides the following facilities

advertisement
Typically, a DBMS provides the following facilities
 Data Definition Language (DDL)
It allows a database designer to define the database using a Data Definition Language
(DDL) provided for the particular DBMS. The DDL allows the designer to specify the
data types and structures, and the constraints on the data to be stored in the database (see
Figure 5.3 on page 60).
 Data Manipulation Language (DML)
It allows users to insert, update, delete and retrieve data from the database through a
Data Manipulation Language (DML). Having a central repository for all data and data
descriptions allows the DML to provide a general enquiry facility to this data, called a
query language. Using a query language, directly or indirectly, enables new lines of
enquiry to be constructed and satisfied quickly. A query language is sufficiently high
level to allow non-technical personnel to use it, easily. The most common query language
is the Structured Query Language (SQL –pronounced ‘S-Q-L’).
 View Mechanism
The DBMS provides a view mechanism that allows each user to have his or her own
view of the database. The DDL is used to define a view that is a subset of the database.
For example, a program to print a list of staff names, their qualifications and subjects that
they teach would be granted a view of the database that included just these data items and
excluded all others as shown in Figure 2.2.
Granted view
Surname
First Name
Qualifications
Main Subject
Address
Salary
Figure 2.2 Restricting an application’s view of the database

Multiple indexes
An index is a mechanism for reducing the time taken to find a specific item of data in a
database. A database index works in a similar way to a user of the index in this book. If
you want to use this book to find out about the topic “multiple indexes“ then you have a
choice. You could open this book at the beginning and work your way, line by line, page
by page, through the text looking for the phrase “multiple indexes”. Eventually, your
search will be successful on page 19. Luckily for you, by choosing the phrase “multiple
indexes” you only had to search 19 pages, had you chosen the phrase “solutions to
questions” you would not have struck lucky until page 107. However, there is a much
 Dr K R Bond 2000
quicker way to search based upon searching the index pages at the back of this book.
Searching the index line by line, page by page for the phrase “multiple indexes” is much
quicker. This index stores the number of the page that we need to visit to read about
“multiple indexes”. So, having found the correct entry in the index we can now turn
directly to the desired page.
An index in a database can store each value of an indexed data item (field), e.g. student
enrolment number, together with the page number in the storage medium where the data
belonging to this value is stored. For example, information stored in a database about a
particular student such as surname, home address, et cetera may be quickly found if an
index has been created that stores every student’s enrolment number and the location of
the corresponding information.
Indexes may also be created on other fields of a student’s record, e.g. surname, address.
However, since some fields such as the surname are unlikely to be unique, the entries in
the index may reference more than one location, just like the entries in the index for this
book. An index on a unique field is known as a primary index whereas an index on a
non-unique field is known as a secondary index.

Indexing Overheads
Indexes have to be constantly kept up to date. When a new data value is added or
modified the corresponding index must be updated. This takes time. This is called an
update overhead.

Three Level Architecture of a DBMS
User 1
External
Schema
or User
Views
Logical or
Conceptual
Schema
Storage
Schema
User 1
View 1
View 2
Base Table 1
Base Table 2
File 1 +
indexes
File 2 +
indexes
File 3 +
indexes
User 1
View 2
Base Table 3
File 4 +
indexes
File 5 +
indexes
 Dr K R Bond 2000
Figure 2.3 Three Level Architecture of a DBMS
The storage schema specifies how the data is actually stored. The logical schema
specifies what data is stored in the database. The external schema specifies what views
of this data are available to users.
Summary of problems solved by the database and database
management approach

Problem: Unproductive maintenance
In a file-based system, where every application shares same view of data, all
applications have to be changed and re-compiled when data structure requirements of
one is changed.
Solution: In a database management system program-data independence or data
independence is enforced via a three level schema architecture consisting of
storage, logical, and user schemas. New data fields may be added/existing
fields may be removed without affecting any existing applications that do
not make use of the fields.

Problem: Data inconsistency
Where each application has its own set of files (application-centred approach) this
means several copies of data are kept and simultaneous alterations to the copies
cannot take place.
Therefore, the copies can become inconsistent with one another.
Solution: In the database approach data is pooled therefore duplication is eliminated
or controlled.
 Problem: Data redundancy
Where each application uses its own files several copies of the data exist that take up
more storage space than is necessary.
Solution: In the database approach data is pooled therefore duplication eliminated or
controlled.

Problem: Security problem
In a file-based approach applications have access to more fields of data than are
essential. This is because the unit of storage is the file. This means it is difficult to
control user access to the data.
Solution: In a database management system users access to data is controlled via the
view mechanism which allows user views (local views / external views) of
the data to be defined. In a database approach the unit of storage is the data
item. Thus access can be restricted to a single item of data if necessary.
 Dr K R Bond 2000

Problem: Data not easily shareable
In a file-based system where each application has its own set of files data is not easily
shareable between applications because
(a) it is held in different files
(b) it could be stored on different computer systems.
Solution: In the database approach the data is made shareable because it is pooled in
one place.

Problem: Slow response to ad-hoc enquiries
In the application-centred approach each new enquiry requires a new file-based
program to be written by an experienced programmer. This is a slow, time-consuming
process.
Solution: Database systems include support for query languages and a mechanism
called Query-By-Example (QBE) which is a form-based method of
interrogating a database. Since query languages and QBE are simple to
learn it is a relatively quick exercise to query a database to obtain an
answer to an ad-hoc enquiry.

Problem: Limited number of ways that data can be selected and retrieved
In the file-based approach there are a limited number of ways that data can be
organised. This in turn means a limited number of ways that data can be accessed and
retrieved from a file.
Solution: The database approach allows data to be accessed and retrieved in many
different ways. It is possible to have multiple indexes. Thus the benefits of,
namely faster retrieval of data, can be applied to many different data items
(fields) in the database.

Problem: Difficult to maintain or to respond to changing requirements and
change of storage medium
In the file-based application-centred approach whole files need to be reconstructed
and application programs altered. This can mean a lot of work much of it
unnecessary.
Solution: In a database management system it is a relatively easy task to add new
fields/tables/alter the storage medium because of level structuring. In this
approach the unit is a data item.
 Dr K R Bond 2000

Problem: Data integrity poorly controlled
In the application-centred or file-based approach it is the programmers’ responsibility
to write program code to validate data entered into the system. This does not always
get done.
 Dr K R Bond 2000
Download