Académique Documents
Professionnel Documents
Culture Documents
The primary
primar goal of a DBMS is to provide
pro ide a way
a to store
and retrieve database information that is both convenient
and efficient
One
One way to keep the information on a computer is to store
it in operating system files
The system
Th t stores
t permanentt records
d in
i various
i fil andd
files,
it needs different application programs to extract records
from and add records to,
from, to the appropriate files
file-processing
fil i system h
has a number
b off major
j
disadvantages:
Data redundancy and inconsistency
-Multiple file formats, duplication of information in different
files
-Example: Savings account and Current account
Data isolation
-Multiple files and formats
Integrity problems
-Values
Values in the database must satisfy constraints
-Hard to add new constraints or change existing ones
Atomicity of updates
-Failures may leave database in an inconsistent state with
partial updates carried out
-Example: Transfer of funds from one account to another
should either complete or not happen at all (atomic)
Security problems
-Hard to provide user access to some, but not all, data
Data Abstraction
For the system
y to be usable,, it must retrieve data efficientlyy
Logical level
Ph i l level
Physical l l
Example:
struct customer
{
customer id: string;
customer_id:
customer_name: string;
customer street: string;
customer_street:
customer_city: string;
};
A banking enterprise may have several such record types,
including
-Account, with fields account_number and account_balance
-Employee, with fields employee_name and
employee salary
employee_salary
At
At the physical level, a customer, account, or employee
record can be described as a block of consecutive storage
locations
The
Th values
l off the
th variables
i bl ini a program att a point
i t in
i time
ti
correspond to an instance of a database schema
Programmers
Programmers develop applications by using the logical
schema
Example
Eachh table
E t bl contains
t i records d off a particular
ti l type.
t E h
Each
record type defines a fixed number of fields, or attributes
Figure 1.3
Object-based
j data models ((Object-oriented
j and Object-
j
relational)
In object-oriented model the data is stored in the form of
objects
bj
The object-relational data model combines features of the
object-oriented
j data model and relational data model
Semistructured data model
Semistructured data models permit the specification of
d where
data h individual
i di id l data
d items
i off the
h same type may have
h
different sets of attributes
This is in contrast with the data models mentioned earlier,
earlier
where every data item of a particular type must have the
same set of attributes
The extensible markup language (XML) is widely used to
represent semistructured data
Network model
Data in this model are represented by collection of records
and relationships among data are connected by links
22 Dustin 7 45.0 101 10/10/98
74 Horatio 9 35 0
35.0 103 9/8/98
Hierarchical model
Hierarchical
Hierarchical model is same as the network model
In this model records are represented in the form of tree
D t D fi iti Language
Data-Definition L
This
This supports the creation, deletion, and modification of
definitions for tables and views
The following statement in the SQL language defines the
account table:
A
A data
d dictionary
di i contains
i metadata—that
t d t th t is,
i data
d t about
b t
data
The schema of a table is an example of metadata
A database system
y consults the data dictionaryy before
reading or modifying actual data
D t M i l ti Language
Data-Manipulation L
Data manipulation is
The retrieval of information stored in the database
The insertion of new information into the database
The deletion of information from the database
The modification of information stored in the database
A data-manipulation language (DML) is a language that
enables
bl users to access or manipulate
i l data
d
There are basically two types:
Procedural DMLs require a user to specify what data are
needed and how to get those data
Declarative DMLs (also referred to as nonprocedural
DMLs)) require
q a user to specify
p y what data are needed
without specifying how to get those data
Data-Control Language
This
Thi subset
b off SQL controls l a database,
d b i l di
including
administrative privileges and saving data
Database Access from Application Programs
Application programs are programs that are used to
i t
interact
t with
ith the
th database
d t b
Application programs are usually written in a host
language such as Cobol,
language, Cobol C,
C C++,
C++ or Java
Examples in a banking system are programs that generate
payroll
p y checks,, debit accounts,, credit accounts,, or transfer
funds between accounts
To access the database, DML statements need to be
executed from the host language
There are two ways to do this:
By providing an application program interface (set of
procedures) that can be used to send DML and DDL
statements to the database, and retrieve the results
The Open Database Connectivity (ODBC) standard defined
by Microsoft for use with the C language is a commonly
used application program interface standard. The Java
Database Connectivity (JDBC) standard provides
corresponding features to the Java language
Storage Manager
A storage manager is a program module that provides the
interface between the low-level data stored in the database
andd the
th application
li ti programs andd queriesi submitted
b itt d to
t the
th
system
The
The storage manager is responsible for the interaction with
the file manager
The raw data are stored on the disk
The storage manager is responsible for storing, retrieving,
and updating data in the database
The storage manager components include:
-Authorization and integrity manager, which tests for the
satisfaction
i f i off integrity
i i constraints
i andd checks
h k theh authority
h i
of users to access data
-Transaction manager,
manager which ensures that the database
remains in a consistent (correct) state despite system
failures,, and that concurrent transaction executions pproceed
without conflicting
-File manager, which manages the allocation of space on
disk storage and the data structures used to represent
information stored on disk
-Buffer manager, which is responsible for fetching data
from disk storage into main memory, and deciding what
data to cache in main memory
The storage manager implements several data structures as
part of the physical system implementation:
-Data files, which store the database itself
-Data
Data dictionary, which stores metadata about the structure
of the database, in particular the schema of the database
-Indices, which provide fast access to data items that hold
particular values
The Query Processor
The qqueryy pprocessor components
p include
-DDL interpreter, which interprets DDL statements and
records the definitions in the data dictionary
‐DML
DML compiler, il which
hi h translates
l DML statements in i a
query language into an evaluation plan consisting of low-
level instructions that the query evaluation engine
understands
--A qquery
y can usuallyy be translated into anyy of a number of
alternative evaluation plans that all give the same result. The
DML compiler also performs query optimization, that is, it
picks the lowest cost evaluation plan from among the
alternatives
-Query
Query evaluation engine,engine which executes low-level
low level
instructions generated by the DML compiler