Database System Architecture (Con)
Database System Architecture
The architecture of a database systems is greatly influenced ) (يتأثر بشكل كبيرby
the underlying computer systems on which it run, in particular:
Networking of computers
Tasks may be executed on servers or clients
Client/ server database systems
Parallel processing
Speed-up the activity of the database systems
Faster response of the transactions
Parallel database system
Distributing data across sites or departments in an organization
Data reside where they are generated, but accessed from remote sites
Keeping multiple copies of the database across different sites
Distributed database systems
2
Centralized Systems
Centralized Systems : Run on a single computer system and do not interact with other
computer systems
E.g. single-user database system on a personal computer
General-purpose computer system consists of one to a few CPUs and a number of
device controllers that are connected through a common bus that provides access to
shared memory.
Two ways of using computers:
Single-user system (e.g., personal computer or workstation): desktop unit, single
user, usually has only one CPU and one or two hard disks; the OS may support only
one user at a time.
Multi-user system: more disks, more memory, multiple CPUs, and a multi-user OS.
Serve a large number of users who are connected to the system via terminals. Often
called server systems. Ex. Unix, thin client and mainframe operating system. In the
Unix server, multiple remote users have the access to the Unix shell at the same
time. In the case of thin client, multiple X Windows sessions are spread across
various terminals. These terminals are powered by a single machine.
3
A Centralized Computer System
4
Centralized Systems
Database systems designed for use by single- users usually do not provide
many facilities as compared to multi-user database.
Do not support concurrency control (not required for a single user)
Provision of crash-recovery is not envisaged (or may be primitive)
Merely making a backup of a database before any update
5
Client-Server Systems
Client server is network architecture which separates a client (often an
application that uses a graphical user interface) from a server. Each instance of
the client software can send requests to a server. While their purposes vary
somewhat, the basic architecture remains the same.
Server systems satisfy requests generated at m client systems, whose general
structure is shown below
Centralized Systems act as Server Systems that satisfy requests generated by
client systems
6
Client-Server Systems (Cont.)
The database functionality can be divided into:
Back-end: manages access structures, query evaluation and optimization,
concurrency control and recovery. (functionality of DBMS)
Front-end: consists of tools such as forms, report-writers, and graphical user
interface facilities.
The interface between the front-end and the back-end is through SQL or
through an application program interface (JDBC, ODBC).
Thanks to standardization the front-end and back-end can be given by different
vendors
7
Client-Server Systems (Cont.)
Advantages of replacing mainframes with networks of workstations or personal
computers connected to back- end server machines:
better functionality for the cost
flexibility in locating resources and expanding facilities
better user interfaces
easier maintenance
8
Server System Architecture
Server systems can be broadly categorized into two kinds:
transaction servers which are widely used in relational database systems,
and
data servers, used in object-oriented database systems
9
Transaction Servers
Transaction server: it is also called query server systems or SQL server
systems; it is an interface with to client requests
Clients send requests to the server system where the transactions are
executed, and results are shipped back to the client.
Requests are specified in SQL, and sent to the server through a remote
procedure call (RPC) mechanism.
Open Database Connectivity (ODBC) is a C language application program
interface standard from Microsoft for connecting to a server, sending SQL
requests, and receiving results.
JDBC standard similar to ODBC, for Java
10
Transaction Server Process Structure
A typical transaction server consists of multiple processes accessing data in
a shared memory.
The processes that form part of the database system include:
Server processes
These processes receive user queries (transactions), execute them and
send the results back,
Processes may be multi-threaded, allowing a single process to execute
several user queries concurrently
Definition: A thread is like a process, but multiple threads execute as part of
the same process.
Lock manager process
This process implements lock manager functionality, which includes
lock grant, lock release, and deadlock detection.
11
Transaction Server Processes (Cont.)
Database writer process
Output modified buffer blocks to disks continually
Log writer process
This process outputs log records from the log record buffer to a stable
storage (hard disk)
Log: history of previous transactions.
Checkpoint process
Performs periodic checkpoints (control procedures)
“Process monitor” process
It monitors other processes, and takes recovery actions if any of the other
processes fail
E.g. aborting any transactions being executed by the failed process and
restarting it.
12
Transaction system Processes (Cont.)
13
Transaction System Processes (Cont.)
Shared memory contains all shared data, such as:
Buffer pool: A buffer pool is memory used to cache table and index data
pages as they are being read from disk, or being modified.
Lock table
Log buffer: containing log records waiting to be output to the log on stable
storage
Cached query plans )((الخطة التى سيتم إتباعها إلحضار البيانات من قاعدة البياناتreused if same
query submitted again)
All database processes can access shared memory
To ensure that no two processes are accessing the same data structure at the
same time, databases systems implement mutual exclusion using either
Operating system semaphores (Flag concept)
A semaphore is a protected variable and constitutes the classic method
for restricting access to equivalent shared resources (e.g. storage) in a
multiprogramming environment. variable multiprogramming
14
Transaction System Processes (Cont.)
To avoid overhead of inter-process communication (message passing) for lock
request/grant, each database process operates directly on the lock table data structure
instead of sending requests to lock manager process
Mutual exclusion ensured on the lock table using semaphores, or more commonly,
atomic instructions
If a lock can be obtained, the lock table is updated directly in shared memory
If a lock cannot be immediately obtained, a lock request is noted in the lock table
and the process (or thread) then waits for lock to be granted
When a lock is released, releasing process updates lock table to record release of
lock, as well as grant of lock to waiting requests (if any)
Process/thread waiting for lock may either:
Continually scan lock table to check for lock grant, or
Use operating system semaphore mechanism to wait on a semaphore.
Semaphore identifier is recorded in the lock table
When a lock is granted, the releasing process signals the semaphore to tell
the waiting process/thread to proceed
Lock manager process still used for deadlock detection
15