41
Distributed Distributed Databases Databases

distributed database system

Embed Size (px)

Citation preview

Page 1: distributed database system

Distributed Databases Distributed Databases

Page 2: distributed database system

Overview of NetworkingOverview of Networking

Network: interconnected collection of autonomous computers, capable of exchanging information.

• Local Area Network (LAN) intended for connecting computers at same site. • Wide Area Network (WAN) used when computers or LANs need to be connected over long distances.

•WAN relatively slow•Less reliable than LANs. •DDBMS using LAN provides much faster response time than one using WAN.

Page 3: distributed database system

Overview of NetworkingOverview of Networking

Network: interconnected collection of autonomous computers, capable of exchanging information.

• Local Area Network (LAN) intended for connecting computers at same site. • Wide Area Network (WAN) used when computers or LANs need to be connected over long distances.

•WAN relatively slow•Less reliable than LANs. •DDBMS using LAN provides much faster response time than one using WAN.

Page 4: distributed database system

Concepts Of Concepts Of Databases Databases and networksand networks::

1.1. A centralized DBMS could be physically processed by several A centralized DBMS could be physically processed by several computers distributed across a networkcomputers distributed across a network

2.2. There could be several There could be several separateseparate DBMS on several computers DBMS on several computers distributed across a networkdistributed across a network

3.3. There may be a Distributed DBMS (DDBMS)There may be a Distributed DBMS (DDBMS)• made up of several DBMSs distributed across a networkmade up of several DBMSs distributed across a network• each with local autonomy each with local autonomy • Each participates in at least one global DBMS actionEach participates in at least one global DBMS action• The DDBMS therefore can operate as a single global DBMSThe DDBMS therefore can operate as a single global DBMS

Page 5: distributed database system

Definition of Distributed Definition of Distributed Database:Database:

A distributed database system consists of a A distributed database system consists of a collection of sites, connected together via collection of sites, connected together via some kind of communication network, in some kind of communication network, in which:which:

a. Each site is a full database system site in its a. Each site is a full database system site in its own right.own right.

b. The sites have agreed to work together so b. The sites have agreed to work together so that a user at any site can access data anywhere that a user at any site can access data anywhere in the network exactly as if the data were all in the network exactly as if the data were all stored at the user’s own site.stored at the user’s own site.

Page 6: distributed database system

Communication

network

New YorkShanghai

London San Francisco

A typical distributed database system:

Page 7: distributed database system

ConceptsConcepts

DDBMS has following characteristics:•Collection of logically-related shared data.•Data split into fragments.•Fragments may be replicated.•Fragments/replicas allocated to sites.•Sites linked by a communication 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.

Page 8: distributed database system

Why need distributed DBWhy need distributed DB

o Organizational and economic reason.Organizational and economic reason.o Interconnection of existing database.Interconnection of existing database.o Incremental growthIncremental growtho Reduced communication overhead.Reduced communication overhead.o Performance considerations.Performance considerations.o Reliability and availability.Reliability and availability.

Page 9: distributed database system

A reference architecture of A reference architecture of DDB DDB

A reference architecture consists of:A reference architecture consists of:●●global schema. global schema. ●●fragmentation schema. fragmentation schema. ●●allocation schema. allocation schema. ●●local mapping schema. local mapping schema.

Page 10: distributed database system

Reference Architecture for Reference Architecture for DDBDDB

●●●●global schema: defines all the data which global schema: defines all the data which are contained in distributed database. are contained in distributed database.

●●fragment: each global relation can be split fragment: each global relation can be split into several non overlapping portion. into several non overlapping portion.

●●●●fragmentation schema: the mapping fragmentation schema: the mapping between global relation and fragment.between global relation and fragment.

●●●●allocation schema: define allocation schema: define at which site a at which site a fragment located.fragment located.

●●●●local mapping schema: depends on the type of local mapping schema: depends on the type of DBMSDBMS ..

Page 11: distributed database system

The Fundamental Principle of The Fundamental Principle of Distributed DatabaseDistributed Database

““To the user, a distributed system To the user, a distributed system should look exactly like a non should look exactly like a non distributed system.”distributed system.”

Fundamental Principle: make distribution transparent to user.

The fact that fragments are stored on different computers is hidden from the users

Page 12: distributed database system

What is the 12 objectives?What is the 12 objectives?

Local autonomyLocal autonomy No reliance on a No reliance on a

central sitecentral site Continuous operationContinuous operation Location Location

independenceindependence Fragmentation Fragmentation

independenceindependence Replication Replication

independenceindependence

Distributed query Distributed query processingprocessing

Distributed transaction Distributed transaction managementmanagement

Hardware independenceHardware independence Operating system Operating system

independenceindependence Network independenceNetwork independence DBMS independenceDBMS independence

Page 13: distributed database system

Why study the 12 Why study the 12 objectives?objectives?

----Useful asUseful as A basis for understanding distributed A basis for understanding distributed

technology in generaltechnology in general A framework for characterizing the A framework for characterizing the

functionality of specific distributed functionality of specific distributed systems.systems.

Page 14: distributed database system

Objective 1Objective 1

Local AutonomyLocal Autonomy All operations at a given site are All operations at a given site are

controlled by that site.controlled by that site. No site X should depend on some No site X should depend on some

other site Y for its successful other site Y for its successful operation.operation.

-- Otherwise site Y is down might mean that -- Otherwise site Y is down might mean that site X is unable to run even if there is nothing site X is unable to run even if there is nothing wrong with site X itself.wrong with site X itself.

Page 15: distributed database system

Objective 2Objective 2No Reliance on a Central SiteNo Reliance on a Central Site

All sites must be treated as equals.All sites must be treated as equals. There must not be any reliance on a There must not be any reliance on a

central “master” site for some central “master” site for some central service—for example, central service—for example, centralized transaction management.centralized transaction management.

Two reasons:Two reasons:1.1. The central site might be a bottleneck.The central site might be a bottleneck.2.2. If the central site went down, the whole system If the central site went down, the whole system

would be down.would be down.

Page 16: distributed database system

Objective 3Objective 3Continuous OperationContinuous Operation

Provide greater reliability and greater Provide greater reliability and greater availability – it is the advantage of availability – it is the advantage of distributed systems in general.distributed systems in general.

Unplanned shutdowns are Unplanned shutdowns are undesirable, but hard to prevent undesirable, but hard to prevent entirely.entirely.

Planned shutdowns should never be Planned shutdowns should never be required.required.

Page 17: distributed database system

Objective 4Objective 4Location IndependenceLocation Independence

Also known as location transparency.Also known as location transparency. Users should not have to know where Users should not have to know where

data is physically stored, but rather data is physically stored, but rather should be able to behave -- as if the should be able to behave -- as if the data were all stored at their own data were all stored at their own local site.local site.

Page 18: distributed database system

Objective 5Objective 5Fragmentation IndependenceFragmentation Independence

A system supports data A system supports data fragmentation if a given base fragmentation if a given base relation can be divided into pieces or relation can be divided into pieces or fragments for physical storage fragments for physical storage purposes.purposes.

Two benefits:Two benefits:

1. most operations are local1. most operations are local

2. reduce network traffic2. reduce network traffic

Page 19: distributed database system

An example of fragmentationAn example of fragmentation Define two fragments:Define two fragments: FRAGMENT EMP ASFRAGMENT EMP AS N_EMP AT SITE ‘New York’ WHERE DEPT# = DEPT#(‘D1’) N_EMP AT SITE ‘New York’ WHERE DEPT# = DEPT#(‘D1’) OR DEPT# = DEPT#(‘D3’)OR DEPT# = DEPT#(‘D3’) S_EMP AT SITE ‘Shanghai’ WHERE DEPT# = DEPT#(‘D2’)S_EMP AT SITE ‘Shanghai’ WHERE DEPT# = DEPT#(‘D2’)

EMP#EMP# DEPT#DEPT# SALARYSALARY

E1E1 D1D1 40K40K

E2E2 D1D1 42K42K

E3E3 D2D2 30K30K

E4E4 D2D2 35K35K

E5E5 D3D3 48K48K

User perception

EMP

EMP#EMP# DEPT#DEPT# SALARYSALARY

E1E1 D1D1 40K40K

E2E2 D1D1 42K42K

E5E5 D3D3 48K48K

EMP#EMP# DEPT#DEPT# SALARYSALARY

E3E3 D2D2 30K30K

E4E4 D2D2 45K45K

New York

N_EMP

Shanghai

S_EMP

Page 20: distributed database system

Objective 6Objective 6

Replication IndependenceReplication Independence A system supports data replication if a given A system supports data replication if a given

base relation or fragment can be represented base relation or fragment can be represented in storage by many distinct copies or in storage by many distinct copies or replicas, stored at many distinct sites.replicas, stored at many distinct sites.

Ideally should be “transparent to the user”.Ideally should be “transparent to the user”.

Desirable for two reasons:Desirable for two reasons: 1. Applications can operate on local copies instead of remote 1. Applications can operate on local copies instead of remote

sites.sites.

2. At least one copy available2. At least one copy available

Page 21: distributed database system

An example of replicationAn example of replication

EMP#EMP# DEPT#DEPT# SALARSALARYY

E1E1 D1D1 40K40K

E2E2 D1D1 42K42K

E5E5 D3D3 48K48K

EMP#EMP# DEPTDEPT##

SALARYSALARY

E3E3 D2D2 30K30K

E4E4 D2D2 35K35K

EMP#EMP# DEPT#DEPT# SALARSALARYY

E3E3 D2D2 30K30K

E4E4 D2D2 35K35K

EMP#EMP# DEPT#DEPT# SALARYSALARY

E1E1 D1D1 40K40K

E2E2 D1D1 42K42K

E5E5 D3D3 48K48K

REPLICATE N_EMP ASREPLICATE N_EMP AS SN_EMP AT SITE ‘Shanghai’;SN_EMP AT SITE ‘Shanghai’; REPLICATE S_EMP ASREPLICATE S_EMP AS NS_EMP AT SITE ‘New York’;NS_EMP AT SITE ‘New York’;

New York

N_EMP

Shanghai

NS_EMP

(S_EMP Replica)

S_EMP

SN_EMP

(N_EMPReplica)

Page 22: distributed database system

Objective 7Objective 7

Distributed Query Distributed Query ProcessingProcessing

A relational distributed system is A relational distributed system is likely to outperform a non relational likely to outperform a non relational one by orders of magnitude.one by orders of magnitude.

The query that involves several sites, The query that involves several sites, there will be many possible ways of there will be many possible ways of moving data around the system.moving data around the system.

Page 23: distributed database system

We now briefly examine three possible strategies for processing this query, and for each strategy calculate the total communication time T from the formula:

( total access delay ) + (total data volume / data rate)

1. Move parts to site A and process the query at A.

T1 = (6.67minutes)

2. Move suppliers and shipments to site B and process the query at B.

T2 = (1.12 hours)

3. Restrict parts at site B to those that are red and move the result to site A. Complete the processing at site A.

T3 = 0.1 second approx.

Page 24: distributed database system

Objective 8Objective 8Distributed Transaction Distributed Transaction

ManagementManagement RecoveryRecovery

The system must ensure that the set of The system must ensure that the set of agents for that transaction either all agents for that transaction either all commit in unison or all roll back in commit in unison or all roll back in unison.unison.

Achieved by two-phase commit protocol.Achieved by two-phase commit protocol. ConcurrencyConcurrency

Typically based on locking.Typically based on locking.

Page 25: distributed database system

Objective 9Objective 9

Hardware IndependenceHardware Independence Real world involves a multiplicity of Real world involves a multiplicity of

different machines—IBM machines, different machines—IBM machines, HP machines, PCs and workstations HP machines, PCs and workstations of various kinds.of various kinds.

Need to be able to integrate the data Need to be able to integrate the data on all of those systems.on all of those systems.

Desirable to be able to run the same Desirable to be able to run the same DBMS on different hardware DBMS on different hardware platform.platform.

Page 26: distributed database system

Objective 10Objective 10Operating System Operating System

IndependenceIndependence Be able to run the same DBMS on Be able to run the same DBMS on

different operating system platforms.different operating system platforms. Have (e.g.) an OS/390 version and a Have (e.g.) an OS/390 version and a

UNIX version and a Windows version UNIX version and a Windows version all participate in the same distributed all participate in the same distributed system.system.

Page 27: distributed database system

Objective 11Objective 11

Network IndepenceNetwork Indepence Desirable to be able to support a Desirable to be able to support a

variety of disparate communication variety of disparate communication networks also.networks also.

Page 28: distributed database system

Objective 12Objective 12

DBMS IndependenceDBMS Independence All needed is that the DBMS All needed is that the DBMS

instances at different sites all instances at different sites all support the same interface– they support the same interface– they don’t necessarily all of the same don’t necessarily all of the same DBMS software.DBMS software.

For example, if Ingres and Oracle both For example, if Ingres and Oracle both supported the official SQL standard, the Ingres supported the official SQL standard, the Ingres site and the Oracle site might be able to talk to site and the Oracle site might be able to talk to each other in a distributed database system.each other in a distributed database system.

Page 29: distributed database system

GATEWAYIngres

(SQL)

Oracle

(SQL)

Ingres

database

Oracle

databaseIngres user

Distributed Ingres database

A hypothetical Ingres–provided gateway to Oracle:

Site X Site Y

Page 30: distributed database system

Types of distributed databaseTypes of distributed database

Homogeneous DBHomogeneous DB

♦ ♦ all sites use the same all sites use the same DBMS sites. DBMS sites.

♦♦ approach provides approach provides incremental growth and incremental growth and allows increased allows increased performance.performance.

Heterogeneous DBHeterogeneous DB

♦ ♦ sites may run different sites may run different DBMS product.DBMS product.

♦ ♦ occur when sites have occur when sites have implemented their own implemented their own database.database.

Page 31: distributed database system

Identical DBMSs

Source: adapted from Bell and Grimson, 1992.

Homogeneous DatabaseHomogeneous Database

Page 32: distributed database system

Heterogeneous Database Heterogeneous Database

Non-identical DBMSs

Source: adapted from Bell and Grimson, 1992.

Page 33: distributed database system

12.3 Introduction

Why use a DDBMS? (!)Why use a DDBMS? (!)Advantages:•Reflects organizational structure•Improved shareability and local autonomy•Improved availability•Improved reliability•Improved performance•Economics•Modular growth

Disadvantages:•Complexity•Cost•Security•Integrity control more difficult•Lack of standards•Lack of experience•Database design more complex

Page 34: distributed database system

Functions of a DDBMSFunctions of a DDBMS• Expect DDBMS to have at least the functionality of a DBMS.

Also to have following functionality:

• Extended communication services.

• Extended Data Dictionary.

• Distributed query processing.

• Extended concurrency control.

• Extended recovery services.

Page 35: distributed database system

Advantages & disadvantages Advantages & disadvantages of of

DDB DDB Advantages: Advantages:

●●increased reliability increased reliability availability. availability.

●●capacity and growth.capacity and growth.

●●efficient & flexibility.efficient & flexibility.

●●distributed database distributed database sharing.sharing.

Disadvantages: Disadvantages:

●●software cost & software cost & complexity. complexity.

●●slow response. slow response.

●●security.security.

●●integrityintegrity

Page 36: distributed database system

12.6 Distributed Relational Database Design

Transparency in a DDBMSTransparency in a DDBMSTransparency hides implementation details from users.

Overall objective: equivalence to user of DDBMs to centralised DBMS

- FULL transparency not universally accepted objective

Four main types:1. Distribution transparency2. Transaction transparency3. Performance transparency

4. DBMS transparency (only applicable to heterogeneous)

Page 37: distributed database system

1. Distribution Transparency1. Distribution TransparencyDistribution transparency: allows user to perceive

database as single, logical entity.

If DDBMS exhibits distribution transparency, user does not need to know:

• fragmentation transparency: data is fragmented • Location transparency: location of data items• otherwise call this local mapping transparency• replication transparency: user unaware of replication of

fragments Naming transparency: each item in a DDB must have a unique name. -One solution: create central name server - loss of some local autonomy. - central site may become a bottleneck. - low availability: if the central site fails.Alternative solution: prefix object with identifier of creator site, each fragment and its copies. Then each site uses alias.

Page 38: distributed database system

12.6 Distributed Relational Database Design

2. Transaction Transparency2. Transaction Transparency

Transaction transparency: Ensures all distributed Ts maintain distributed database’s integrity and consistency.

• Distributed T accesses data stored at more than one location. • Each T is divided into no. of subTs or agents, one for each site that

has to be accessed.• DDBMS must ensure the indivisibility of both the global T and each

of the subTs.

Page 39: distributed database system

12.6 Distributed Relational Database Design

2. Transaction Transparency2. Transaction Transparency

Concurrency transparency: All Ts must execute independently and be logically consistent with results obtained if Ts executed in some arbitrary serial order. • Replication makes concurrency more complex

Failure transparency: must ensure atomicity and durability of global T. • Means ensuring that subTs of global T either all commit or

all abort.

Page 40: distributed database system

12.6 Distributed Relational Database Design

3. Performance 3. Performance TransparencyTransparency

DDBMS: - no performance degradation due to distributed architecture.

- determine most cost-effective strategy to execute a request.

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:1. which fragment to access2. which copy of a fragment to use3. which location to use.

- 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.

Page 41: distributed database system

Thank you!Thank you!