Download DataBase Development and Implementation Lec16 - Distributed DBMS and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!
DBDI/ Lecture 16
Distributed DBMS
Dr. Ala Al-Zobaidie & Mr. Alun Butler
The slides are based on the textbook Database Systems by Thomas Connolly & Carolyn Begg
30/05/2007 DBDI /DDB 2
Objectives
• Evolution & Concepts
• Advantages and disadvantages of
distributed databases.
• Functions and architecture for a DDBMS.
• Distributed database design.
• Levels of transparency.
• Replicated DB vs. Distributed DB
30/05/2007 DBDI /DDB 3
Evolution
• DDB technology represent the merging of
two diverging concepts:
- Integration through the use of database
technology, and
- Distribution through the use of data
communications technology.
30/05/2007 DBDI /DDB 4
Concepts
• Distributed Database
- A logically interrelated collection of shared data (and a description of this data), physically distributed over a computer network.
• Distributed DBMS
- Software system that permits the management of the distributed database and makes the distribution transparent to users.
Concepts
- Collection of logically-related shared data.
- Data split into fragments.
- Fragments may be replicated.
- Fragments/replicas allocated to sites.
- Sites linked by a communications network.
- Data at each site is under control of a DBMS.
- DBMSs handle local applications autonomously.
- Each DBMS participates in at least one global application.
Distributed DBMS
It is not necessary for every site in the system to have its own local DB
It is not necessary for every site in the system to have its own local DB
30/05/2007 DBDI /DDB 7
Distributed Processing
A centralized database that can be accessed over a computer network.
Data physically centralised, even if it can be accessed remotely.
Data physically centralised, even if it can be accessed remotely.
30/05/2007 DBDI /DDB 8
Distributed Processing: File-server Architecture
Application Program
Typical Workstation DB
DBMS
Application Program
DBMS
FileFile ServerServer
Disk I/O requests Disk blocks
Server System
30/05/2007 DBDI /DDB 9
Distributed Processing: File-server
- File-server is connected to several workstations across a network.
- Database resides on file-server.
- DBMS & applications run on each workstation.
- Disadvantages include:
- Significant network traffic.
- Copy of DBMS on each workstation.
- Concurrency, recovery and integrity control more complex.
30/05/2007 DBDI /DDB 10
Application Program
Typical Client PCs DB
Application Program
DBMSDBMS including SQLinterpreter
SQL requests Database rows (page)
Server System
Distributed Processing: SQL Client-server Architecture
- Server holds the DB & the DBMS.
- Client manages the UI & runs applications.
Distributed Processing: Client-server
- Advantages include:
- Scalability
- Wider access to existing databases.
- Open system (encourages the use of mixture of different H/W & S/W systems
- Increased performance.
- Distribution of specialised tasks (distribution of C/S roles)
- Reduction in communication costs
- Possible reduction in hardware costs.
- Increased consistency.
- Modularity of implementation
Summary of Client-server Functions
- 2-tier vs. 3-tier Architecture
- thick client vs. thin client
30/05/2007 DBDI /DDB 19
Multidatabase System (MDBS)
- Attempt to logically integrate DDBSs while allowing each site maintains complete autonomy.
- It is a DBMS that resides transparently on top of existing database and file systems and presents a single database to its users.
- Allows users to access and share data without requiring physical database integration.
- Unfederated MDBS & federated MDBS.
- Unfederated means no local users
- Federated MDBS is a distributed system for global users & centralised system for local users.
30/05/2007 DBDI /DDB 20
Reference Architecture for DDBMS
- Due to diversity, no accepted architecture equivalent to ANSI/SPARC 3-level architecture.
- A reference architecture consists of:
- Set of global external schemas.
- Global conceptual schema (GCS).
- Fragmentation schema and allocation schema.
- Set of schemas for each local DBMS conforming to 3- level ANSI/SPARC.
- Some levels may be missing, depending on levels of transparency supported.
30/05/2007 DBDI /DDB 21
Reference Architecture for DDBMS
Union of all underlying local data descriptions (not specified in the local schemas) & user views are defined against it.
Consists of the description of all the data in that DB
Describes how the global relations are divided amongst the local DBs (Logical Partition)
Specifies at which site each fragment is stored (Physical Partition)
30/05/2007 DBDI /DDB 22
Reference Architecture for MDBS
- In DDBMS, GCS is union of all local conceptual schemas.
- In FMDBS, GCS is subset of local conceptual schemas (LCS), consisting of data that each local system agrees to share.
- GCS of tightly coupled system involves integration of either parts of LCSs or local external schemas.
- FMDBS with no GCS is called loosely coupled.
Reference Architecture for Tightly-Coupled
FMDBS
Components of a DDBMS
Software that enables all sites to communicate with each other
Global System Catalog holds the fragmentation & allocation schemas
Local DBMS responsible for controlling local data
Distributed DBMS responsible for distributed functionalities (next slide)
30/05/2007 DBDI /DDB 25
Functions of a DDBMS
- Expect DDBMS to have at least the
functionality of a centralized DBMS.
- Also to have following functionality:
- Extended communication services.
- Extended Data Dictionary.
- Distributed query processing.
- Extended concurrency control.
- Extended recovery services.
30/05/2007 DBDI /DDB 26
Distributed Database Design
- Fragmentation
- Relation may be divided into a number of sub-relations, which are then distributed.
P# Pname Colour Weight City P1 Nut Red 12 London P2 Bolt Green 17 Paris P3 Screw Blue 17 Rome P4 Screw Red 14 London
- Allocation
- Each fragment is stored at site with "optimal" distribution.
- Replication
- Copy of fragment may be maintained at several sites.
30/05/2007 DBDI /DDB 27
Fragmentation
- Definition and allocation of fragments
carried out strategically to achieve:
- Locality of Reference
- Improved Reliability and Availability
- Improved Performance
- Balanced Storage Capacities and Costs
- Minimal Communication Costs.
- Involves analyzing most important
applications, based on quantitative/qualitative information. 30/05/2007 DBDI /DDB 28
Fragmentation
- Quantitative information may include:
- frequency with which an application is run;
- site from which an application is run;
- performance criteria for transactions and applications.
- Qualitative information may include:
- transactions that are executed by application;
- type of access (read or write), and
- predicates of read operations.
Data Allocation
- Four alternative strategies regarding
placement of data:
- Centralized
- Partitioned (or Fragmented)
- Complete Replication
- Selective Replication
Data Allocation
- Centralized
- Consists of single database and DBMS stored at one site with users distributed across the network. (not a true distribution)!
- Partitioned
- Database partitioned into disjoint fragments, each fragment assigned to one site.
30/05/2007 DBDI /DDB 37
Correctness of Fragmentation
- Disjointness
- If data item d (^) i appears in fragment R (^) i , then it should not appear in any other fragment.
- Exception:
- vertical fragmentation, where primary key attributes must be repeated to allow reconstruction.
- For horizontal fragmentation, data item is a tuple
- For vertical fragmentation, data item is an attribute.
30/05/2007 DBDI /DDB 38
Types of Fragmentation
- Four types of fragmentation:
- Horizontal
- Vertical
- Mixed
- Derived.
- Other possibility is no fragmentation:
- If relation is small and not updated frequently, may be better not to fragment relation.
30/05/2007 DBDI /DDB 39
Horizontal and Vertical Mixed Fragmentation Reconstructing the original relation from the vertical fragments is done via a suitable join operation, & from horizontal fragments via the union operation.
Fragmentation
30/05/2007 DBDI /DDB 40
Fragmentation Example
- EMPLOYEE (Empnum, Name, Deptnum, Salary, Taxes )
- Horizontal fragmentation
- EMPLOYEE1 = σ (^) Empnum<=3 EMPLOYEE
- EMPLOYEE2 = σ Empnum>3 EMPLOYEE
- Reconstruction requires a union:
- EMPLOYEE = EMPLOYEE1 ∪ EMPLOYEE
- Vertical fragmentation:
- EMPLOYEE1 = Π (^) EmpNum,Name EMPLOYEE
- EMPLOYEE2 = Π (^) EmpNum,DeptName,Salary,Tax EMPLOYEE
- Reconstruction requires an Equijoin on key values (natural join).
- EMPLOYEE = EMPLOYEE1 EMPLOYEE
Fragmentation
- Horizontal
- Consists of a subset of the tuples of a relation.
- Defined using Selection operation of relational algebra.
- Vertical
- Consists of a subset of attributes of a relation.
- Defined using Projection operation of relational algebra.
Fragmentation
- Mixed
- Consists of a horizontal fragment that is vertically fragmented, or a vertical fragment that is horizontally fragmented.
- Defined using Selection and Projection operations of relational algebra
- Derived
- A horizontal fragment that is based on horizontal fragmentation of a parent relation.
- Ensures that fragments that are frequently joined together are at same site.
- Defined using Semi-Join operation of relational algebra.
30/05/2007 DBDI /DDB 43
Transparencies in a DDBMS
- Distribution Transparency
- Fragmentation Transparency
- Location Transparency
- Replication Transparency
- Local Mapping Transparency
- Naming Transparency
30/05/2007 DBDI /DDB 44
Transparencies in a DDBMS
- Transaction Transparency
- Concurrency Transparency
- Failure Transparency
- Performance Transparency
- DBMS Transparency
30/05/2007 DBDI /DDB 45
Distribution Transparency
- Distribution transparency allows user to perceive database as single, logical entity.
- If DDBMS exhibits distribution transparency, user does not need to know: - data is fragmented (fragmentation transparency), - location of data items (location transparency), - otherwise call this local mapping transparency. -
- With replication transparency, user is unaware of replication of fragments.
30/05/2007 DBDI /DDB 46
Naming Transparency
- Each item in a DDB must have a unique name.
- DDBMS must ensure that no two sites create a database object with same name.
- One solution is to create central name server. However, this results in: - loss of some local autonomy; - central site may become a bottleneck; - low availability; if the central site fails, remaining sites cannot create any new objects.
Naming Transparency
- Alternative solution - prefix object with identifier of site that created it.
- For example, Branch created at site S1 might be named S1.BRANCH.
- Also need to identify each fragment and its copies.
- Thus, copy 2 of fragment 3 of Branch created at site S might be referred to as S1.BRANCH.F3.C2.
- However, this results in loss of distribution transparency.
- An approach that resolves these problems uses aliases for each database object.
- Thus, S1.BRANCH.F3.C2 might be known as local_branch by user at site S1.
Transaction Transparency
- Ensures that all distributed transactions maintain distributed database’s integrity and consistency.
- Distributed transaction accesses data stored at more than one location.
- Each transaction is divided into number of subtransactions, one for each site that has to be accessed.
- DDBMS must ensure the indivisibility of both the global transaction and each subtransactions.
30/05/2007 DBDI /DDB 55
DB
Data
DB
Data
Global Abort Steps Under 2PC
Vote
Wait Wait
z z z (^) z z z
Commit
Global Abort
Acknowledgement
Wait z z z
z z z
Commit^^ Abort Local abortprocessing
Abort^
Commit Commit
DB
Data
Ack’ment
30/05/2007 DBDI /DDB 56
2PC Protocol for Participant Voting Commit
30/05/2007 DBDI /DDB 57
2PC Protocol for Participant Voting Abort
30/05/2007 DBDI /DDB 58
Performance Transparency
- DDBMS must perform as if it were a centralized DBMS. - DDBMS should not suffer any performance degradation due to distributed architecture. - DDBMS should determine most cost-effective strategy to execute a request.
Performance Transparency
- Distributed Query Processor (DQP) maps data request into ordered sequence of operations on local databases.
- Must consider fragmentation, replication, and allocation schemas.
- DQP has to decide:
- which fragment to access;
- which copy of a fragment to use;
- which location to use.
30/05/2007 DBDI /DDB 61
Performance Transparency
- DQP produces execution strategy optimized with respect to some cost function.
- Typically, costs associated with a distributed request include: - I/O cost; - CPU cost; - communication cost.
30/05/2007 DBDI /DDB 62
Distributed Query Optimization
30/05/2007 DBDI /DDB 63
Distributed Query Optimization
- Query decomposition: takes query expressed on global relations and performs partial optimization using centralized QO techniques. Output is some form of Relational Algebra Tree based on global relations.
- Data localization: takes into account how data has been distributed. Replace global relations at leaves of RAT with their reconstruction algorithms.
30/05/2007 DBDI /DDB 64
Distributed Query Optimization
- Global optimization: uses statistical information to find a near-optimal execution plan. Output is execution strategy based on fragments with communication primitives added.
- Local optimization: Each local DBMS performs its own local optimization using centralized QO techniques.
Performance Transparency - Example
- Property (Pno, City)
- Renter (Rno,Max_Price)
- 100000 records in Glasgow
- Viewing (Pno, Rno)
- 1000000 records in London
SELECT p.pno FROM property p, renter r, viewing v WHERE r.rno = v.rno AND p.pno = v.pno AND p.city=‘Aberdeen’ AND r.max_price > 200000;
Performance Transparency - Example
Assume:
- Each tuple in each relation is 100 characters long.
- 10 renters with maximum price greater than £200,000.
- 100 000 viewings for properties in Aberdeen.
- Computation time negligible compared to communication time.
30/05/2007 DBDI /DDB 73
Applications of Replication
- Replication supports a variety of applications that have very different requirements.
- Some applications are supported with only limited synchronization between the copies of the database and the central database system.
- Other applications demand continuous synchronization between all copies of the database.
30/05/2007 DBDI /DDB 74
Basic Components of Database Replication
- Replication object is a database object such as a relation, index, view, procedure, or function existing on multiple servers in a distributed database system.
- In a replication environment, any updates made to a replication object at one site are applied to the copies at all other sites.
Date’s 12 Rules for a DDBMS
Fundamental Principle
To the user, a distributed system should look exactly like a non distributed system.
- Local Autonomy
- No Reliance on a Central Site
- Continuous Operation
- Location Independence
- Fragmentation Independence
- Replication Independence
Date’s 12 Rules for a DDBMS
- Distributed Query Processing
- Distributed Transaction Processing
- Hardware Independence
- Operating System Independence
- Network Independence
- Database Independence