mdm7e_ch13

40
© 2005 by Prentice Hall © 2005 by Prentice Hall 1 Chapter 13: Chapter 13: Distributed Databases Distributed Databases Modern Database Management Modern Database Management 7 7 th th Edition Edition Jeffrey A. Hoffer, Mary B. Prescott, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden Fred R. McFadden

Upload: sohel12345

Post on 03-Dec-2014

109 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: mdm7e_Ch13

© 2005 by Prentice Hall© 2005 by Prentice Hall 11

Chapter 13:Chapter 13: Distributed Databases Distributed Databases

Modern Database Modern Database ManagementManagement

77thth Edition EditionJeffrey A. Hoffer, Mary B. Prescott, Jeffrey A. Hoffer, Mary B. Prescott,

Fred R. McFaddenFred R. McFadden

Page 2: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 22

ObjectivesObjectives Definition of termsDefinition of terms Explain business conditions driving distributed Explain business conditions driving distributed

databasesdatabases Describe salient characteristics of distributed Describe salient characteristics of distributed

database environmentsdatabase environments Explain advantages and risks of distributed databasesExplain advantages and risks of distributed databases Explain strategies and options for distributed Explain strategies and options for distributed

database designdatabase design Discuss synchronous and asynchronous data Discuss synchronous and asynchronous data

replication and partitioningreplication and partitioning Discuss optimized query processing in distributed Discuss optimized query processing in distributed

databasesdatabases Explain salient features of several distributed Explain salient features of several distributed

database management systemsdatabase management systems

Page 3: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 33

DefinitionsDefinitions Distributed Database:Distributed Database: A A single single

logical databaselogical database that is spread that is spread physically across computers in multiple physically across computers in multiple locations that are connected by a data locations that are connected by a data communications linkcommunications link

Decentralized Database:Decentralized Database: A collection A collection of of independentindependent databases on non- databases on non-networked computersnetworked computers

They are NOT the same thing!

Page 4: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 44

Reasons forReasons forDistributed DatabaseDistributed Database

Business unit autonomy and distributionBusiness unit autonomy and distribution Data sharingData sharing Data communication costsData communication costs Data communication reliability and costsData communication reliability and costs Multiple application vendorsMultiple application vendors Database recoveryDatabase recovery Transaction and analytic processingTransaction and analytic processing

Page 5: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 55

Figure 13-1 – Distributed database environments (adapted from Bell and Grimson, 1992)

Page 6: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 66

Distributed Database Distributed Database OptionsOptions

Homogeneous - Same DBMS at each nodeHomogeneous - Same DBMS at each node Autonomous - Independent DBMSsAutonomous - Independent DBMSs Non-autonomous - Central, coordinating DBMSNon-autonomous - Central, coordinating DBMS Easy to manage, difficult to enforceEasy to manage, difficult to enforce

Heterogeneous - Different DBMSs at different Heterogeneous - Different DBMSs at different nodesnodes Systems – With full or partial DBMS functionalitySystems – With full or partial DBMS functionality Gateways - Simple paths are created to other Gateways - Simple paths are created to other

databases without the benefits of one logical databasedatabases without the benefits of one logical database Difficult to manage, preferred by independent Difficult to manage, preferred by independent

organizationsorganizations

Page 7: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 77

Distributed Database Options Distributed Database Options (cont.)(cont.)

SystemsSystems - Supports some or all functionality of - Supports some or all functionality of one logical databaseone logical database Full DBMS Functionality - All distributed DB functionsFull DBMS Functionality - All distributed DB functions Partial-Multi database - Some distributed DB Partial-Multi database - Some distributed DB

functionsfunctions Federated - Supports local databases for unique data Federated - Supports local databases for unique data

requestsrequests Loose Integration - Local dbs have their own schemasLoose Integration - Local dbs have their own schemas Tight Integration - Local dbs use common schemaTight Integration - Local dbs use common schema

Unfederated - Requires all access to go through a central, Unfederated - Requires all access to go through a central, coordinating modulecoordinating module

Page 8: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 88

Homogeneous, Non-Homogeneous, Non-Autonomous DatabaseAutonomous Database

Data is distributed across all the nodesData is distributed across all the nodes Same DBMS at each nodeSame DBMS at each node All data is managed by the distributed All data is managed by the distributed

DBMS (no exclusively local data)DBMS (no exclusively local data) All access is through one, global All access is through one, global

schemaschema The global schema is the The global schema is the unionunion of all of all

the local schemathe local schema

Page 9: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 99

Identical DBMSs

Figure 13-2: Homogeneous Database

Source: adapted from Bell and Grimson, 1992.

Page 10: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1010

Typical Heterogeneous Typical Heterogeneous EnvironmentEnvironment

Data distributed across all the nodesData distributed across all the nodes Different DBMSs may be used at each Different DBMSs may be used at each

nodenode Local access is done using the local Local access is done using the local

DBMS and schemaDBMS and schema Remote access is done using the Remote access is done using the

global schemaglobal schema

Page 11: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1111

Figure 13-3: Typical Heterogeneous Environment

Non-identical DBMSs

Source: adapted from Bell and Grimson, 1992.

Page 12: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1212

Major ObjectivesMajor Objectives

Location Transparency Location Transparency User does not have to know the location of User does not have to know the location of

the datathe data Data requests automatically forwarded to Data requests automatically forwarded to

appropriate sitesappropriate sites Local Autonomy Local Autonomy

Local site can operate with its database Local site can operate with its database when network connections failwhen network connections fail

Each site controls its own data, security, Each site controls its own data, security, logging, recoverylogging, recovery

Page 13: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1313

Significant Trade-OffsSignificant Trade-Offs SynchronousSynchronous Distributed Database Distributed Database

All copies of the same data are always identicalAll copies of the same data are always identical Data updates are immediately applied to all Data updates are immediately applied to all

copies throughout networkcopies throughout network Good for data integrityGood for data integrity High overhead High overhead slow response times slow response times

AsynchronousAsynchronous Distributed Database Distributed Database Some data inconsistency is toleratedSome data inconsistency is tolerated Data update propagation is delayedData update propagation is delayed Lower data integrityLower data integrity Less overhead Less overhead faster response time faster response time

NOTE: all this assumes replicated data (to be discussed later)

Page 14: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1414

Advantages ofAdvantages ofDistributed Database over Distributed Database over

Centralized DatabasesCentralized Databases

Increased reliability/availabilityIncreased reliability/availability Local control over dataLocal control over data Modular growthModular growth Lower communication costsLower communication costs Faster response for certain queriesFaster response for certain queries

Page 15: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1515

Disadvantages ofDisadvantages ofDistributed Database Distributed Database

Compared to Compared to Centralized DatabasesCentralized Databases

Software cost and complexitySoftware cost and complexity Processing overheadProcessing overhead Data integrity exposureData integrity exposure Slower response for certain queriesSlower response for certain queries

Page 16: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1616

Options forOptions forDistributing a DatabaseDistributing a Database

Data replication Data replication Copies of data distributed to different sitesCopies of data distributed to different sites

Horizontal partitioningHorizontal partitioning Different rows of a table distributed to different sitesDifferent rows of a table distributed to different sites

Vertical partitioningVertical partitioning Different columns of a table distributed to different Different columns of a table distributed to different

sitessites Combinations of the aboveCombinations of the above

Page 17: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1717

Data ReplicationData Replication Advantages: Advantages:

ReliabilityReliability Fast responseFast response May avoid complicated distributed May avoid complicated distributed

transaction integrity routines (if replicated transaction integrity routines (if replicated data is refreshed at scheduled intervals)data is refreshed at scheduled intervals)

Decouples nodes (transactions proceed Decouples nodes (transactions proceed even if some nodes are down)even if some nodes are down)

Reduced network traffic at prime time (if Reduced network traffic at prime time (if updates can be delayed)updates can be delayed)

Page 18: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1818

Data Replication (cont.)Data Replication (cont.)

Disadvantages: Disadvantages: Additional requirements for storage spaceAdditional requirements for storage space Additional time for update operationsAdditional time for update operations Complexity and cost of updatingComplexity and cost of updating Integrity exposure of getting incorrect Integrity exposure of getting incorrect

data if replicated data is not updated data if replicated data is not updated simultaneouslysimultaneously

Therefore, better when used for non-volatile Therefore, better when used for non-volatile (read-only) data(read-only) data

Page 19: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 1919

Types of Data ReplicationTypes of Data Replication

Push Replication – Push Replication – updating site sends updating site sends changes to other siteschanges to other sites

Pull Replication – Pull Replication – receiving sites control receiving sites control when update messages when update messages will be processedwill be processed

Page 20: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2020

Types of Push ReplicationTypes of Push Replication Snapshot Replication - Snapshot Replication -

Changes periodically sent to master site Changes periodically sent to master site Master collects updates in logMaster collects updates in log Full or differential (incremental) snapshotsFull or differential (incremental) snapshots Dynamic vs. shared update ownershipDynamic vs. shared update ownership

Near Real-Time Replication -Near Real-Time Replication - Broadcast update orders without requiring Broadcast update orders without requiring

confirmationconfirmation Done through use of triggersDone through use of triggers Update messages stored in message queue Update messages stored in message queue

until processed by receiving siteuntil processed by receiving site

Page 21: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2121

Issues for Data ReplicationIssues for Data Replication

Data timeliness – high tolerance for out-of-date Data timeliness – high tolerance for out-of-date data may be requireddata may be required

DBMS capabilities – if DBMS cannot support multi-DBMS capabilities – if DBMS cannot support multi-node queries, replication may be necessarynode queries, replication may be necessary

Performance implications – refreshing may cause Performance implications – refreshing may cause performance problems for busy nodesperformance problems for busy nodes

Network heterogeneity – complicates replicationNetwork heterogeneity – complicates replication Network communication capabilities – complete Network communication capabilities – complete

refreshes place heavy demand on refreshes place heavy demand on telecommunicationstelecommunications

Page 22: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2222

Horizontal PartitioningHorizontal Partitioning Different rows of a table at different sitesDifferent rows of a table at different sites Advantages -Advantages -

Data stored close to where it is used Data stored close to where it is used efficiency efficiency Local access optimization Local access optimization better performance better performance Only relevant data is available Only relevant data is available security security Unions across partitions Unions across partitions ease of query ease of query

DisadvantagesDisadvantages Accessing data across partitions Accessing data across partitions inconsistent inconsistent

access speedaccess speed No data replication No data replication backup vulnerability backup vulnerability

Page 23: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2323

Vertical PartitioningVertical Partitioning

Different columns of a table at Different columns of a table at different sitesdifferent sites

Advantages and disadvantages are Advantages and disadvantages are the same as for horizontal the same as for horizontal partitioning except that combining partitioning except that combining data across partitions is more data across partitions is more difficult because it requires joins difficult because it requires joins (instead of unions)(instead of unions)

Page 24: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2424

Figure 13-6 Distributed processing system for a manufacturing company

Page 25: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2525

Five Distributed Database Five Distributed Database OrganizationsOrganizations

Centralized database, distributed accessCentralized database, distributed access Replication with periodic snapshot Replication with periodic snapshot

updateupdate Replication with near real-time Replication with near real-time

synchronization of updatessynchronization of updates Partitioned, one logical databasePartitioned, one logical database Partitioned, independent, nonintegrated Partitioned, independent, nonintegrated

segmentssegments

Page 26: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2626

Factors in Choice ofFactors in Choice ofDistributed StrategyDistributed Strategy

Funding, autonomy, securityFunding, autonomy, security Site data referencing patternsSite data referencing patterns Growth and expansion needsGrowth and expansion needs Technological capabilitiesTechnological capabilities Costs of managing complex Costs of managing complex

technologiestechnologies Need for reliable serviceNeed for reliable service

Page 27: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2727

Table 13-1: Distributed Design Strategies

Page 28: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2828

Distributed DBMSDistributed DBMS Distributed databaseDistributed database requires requires distributed distributed

DBMSDBMS Functions of a distributed DBMS:Functions of a distributed DBMS:

Locate data with a Locate data with a distributed data dictionarydistributed data dictionary Determine location from which to retrieve data and Determine location from which to retrieve data and

process query componentsprocess query components DBMS translation between nodes with different local DBMS translation between nodes with different local

DBMSs (using DBMSs (using middlewaremiddleware)) Data consistency (via Data consistency (via multiphase commit protocolsmultiphase commit protocols)) Global primary key controlGlobal primary key control ScalabilityScalability Security, concurrency, query optimization, failure Security, concurrency, query optimization, failure

recoveryrecovery

Page 29: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 2929

Figure 13-10: Distributed DBMS architecture

Page 30: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3030

Local Transaction StepsLocal Transaction Steps1.1. Application makes request to Application makes request to

distributed DBMSdistributed DBMS2.2. Distributed DBMS checks distributed Distributed DBMS checks distributed

data repository for location of data. data repository for location of data. Finds that it is Finds that it is locallocal

3.3. Distributed DBMS sends request to Distributed DBMS sends request to local DBMSlocal DBMS

4.4. Local DBMS processes requestLocal DBMS processes request5.5. Local DBMS sends results to applicationLocal DBMS sends results to application

Page 31: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3131

Figure 13-10: Distributed DBMS Architecture (cont.) (showing local transaction steps)

Local transaction – all data stored locally

1

3

4

5

2

Page 32: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3232

Global Transaction StepsGlobal Transaction Steps1.1. Application makes request to distributed DBMSApplication makes request to distributed DBMS2.2. Distributed DBMS checks distributed data repository for Distributed DBMS checks distributed data repository for

location of data. Finds that it is location of data. Finds that it is remoteremote3.3. Distributed DBMS routes request to remote siteDistributed DBMS routes request to remote site4.4. Distributed DBMS at remote site translates request for its Distributed DBMS at remote site translates request for its

local DBMS if necessary, and sends request to local DBMSlocal DBMS if necessary, and sends request to local DBMS5.5. Local DBMS at remote site processes requestLocal DBMS at remote site processes request6.6. Local DBMS at remote site sends results to distributed Local DBMS at remote site sends results to distributed

DBMS at remote siteDBMS at remote site7.7. Remote distributed DBMS sends results back to Remote distributed DBMS sends results back to

originating siteoriginating site8.8. Distributed DBMS at originating site sends results to Distributed DBMS at originating site sends results to

applicationapplication

Page 33: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3333

Figure 13-10: Distributed DBMS architecture (cont.) (showing global transaction steps)

Global transaction – some data is at remote site(s)

1

2

4

5

6

3

7

8

Page 34: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3434

Distributed DBMSDistributed DBMSTransparency ObjectivesTransparency Objectives

Location TransparencyLocation Transparency User/application does not need to know where data User/application does not need to know where data

residesresides Replication TransparencyReplication Transparency

User/application does not need to know about duplicationUser/application does not need to know about duplication Failure TransparencyFailure Transparency

Either all or none of the actions of a transaction are Either all or none of the actions of a transaction are committedcommitted

Each site has a transaction managerEach site has a transaction manager Logs transactions and before and after imagesLogs transactions and before and after images Concurrency control scheme to ensure data integrityConcurrency control scheme to ensure data integrity

Requires special Requires special commit protocolcommit protocol

Page 35: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3535

Two-Phase CommitTwo-Phase Commit Prepare PhasePrepare Phase

Coordinator receives a commit requestCoordinator receives a commit request Coordinator instructs all resource managers Coordinator instructs all resource managers

to get ready to “go either way” on the to get ready to “go either way” on the transaction. Each resource manager writes transaction. Each resource manager writes all updates from that transaction to its own all updates from that transaction to its own physical logphysical log

Coordinator receives replies from all Coordinator receives replies from all resource managers. If all are ok, it writes resource managers. If all are ok, it writes commit to its own log; if not then it writes commit to its own log; if not then it writes rollback to its logrollback to its log

Page 36: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3636

Two-Phase Commit (cont.)Two-Phase Commit (cont.)

Commit PhaseCommit Phase Coordinator then informs each resource Coordinator then informs each resource

manager of its decision and broadcasts a manager of its decision and broadcasts a message to either commit or rollback (abort). message to either commit or rollback (abort). If the message is commit, then each resource If the message is commit, then each resource manager transfers the update from its log to its manager transfers the update from its log to its databasedatabase

A failure during the commit phase puts a A failure during the commit phase puts a transaction “in limbo.” This has to be tested transaction “in limbo.” This has to be tested for and handled with timeouts or pollingfor and handled with timeouts or polling

Page 37: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3737

Concurrency ControlConcurrency Control

Concurrency TransparencyConcurrency Transparency Design goal for distributed databaseDesign goal for distributed database

TimestampingTimestamping Concurrency control mechanismConcurrency control mechanism Alternative to locks in distributed Alternative to locks in distributed

databasesdatabases

Page 38: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3838

Query OptimizationQuery Optimization

In a query involving a multi-site join and, possibly, a In a query involving a multi-site join and, possibly, a distributed database with replicated files, the distributed database with replicated files, the distributed DBMS must decide where to access the distributed DBMS must decide where to access the data and how to proceed with the join. Three step data and how to proceed with the join. Three step process:process:1 Query decompositionQuery decomposition - rewritten and simplified - rewritten and simplified2 Data localizationData localization - query fragmented so that - query fragmented so that

fragments reference data at only one sitefragments reference data at only one site3 Global optimizationGlobal optimization - -

Order in which to execute query fragmentsOrder in which to execute query fragments Data movement between sitesData movement between sites Where parts of the query will be executedWhere parts of the query will be executed

Page 39: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 3939

Evolution of Distributed Evolution of Distributed DBMSDBMS

““Unit of Work” - All of a transaction’s Unit of Work” - All of a transaction’s steps.steps.

Remote Unit of WorkRemote Unit of Work SQL statements originated at one location SQL statements originated at one location

can be executed as a single unit of work on can be executed as a single unit of work on a single remote DBMSa single remote DBMS

Page 40: mdm7e_Ch13

Chapter 13 © 2005 by Prentice Hall© 2005 by Prentice Hall 4040

Evolution of Distributed DBMS Evolution of Distributed DBMS (cont.)(cont.)

Distributed Unit of WorkDistributed Unit of Work Different statements in a unit of work may Different statements in a unit of work may

refer to different remote sitesrefer to different remote sites All databases in a single SQL statement All databases in a single SQL statement

must be at a single sitemust be at a single site Distributed RequestDistributed Request

A single SQL statement may refer to tables A single SQL statement may refer to tables in more than one remote sitein more than one remote site

May not support replication transparency or May not support replication transparency or failure transparencyfailure transparency