Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee...

25
Distributed Distributed Databases Databases and Its Twelve and Its Twelve Objectives Objectives CS157B CS157B Name: Yingying Wu Name: Yingying Wu Professor: Sin-Min Lee Professor: Sin-Min Lee Reference Book: Reference Book: An introduction to Database Systems An introduction to Database Systems By C.J.Date By C.J.Date

Transcript of Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee...

Page 1: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

Distributed Databases Distributed Databases and Its Twelve and Its Twelve

ObjectivesObjectives

CS157BCS157BName: Yingying WuName: Yingying Wu

Professor: Sin-Min LeeProfessor: Sin-Min Lee

Reference Book: Reference Book: An introduction to Database SystemsAn introduction to Database Systems

By C.J.DateBy C.J.Date

Page 2: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 3: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

Communication

network

New YorkShanghai

London San Francisco

A typical distributed database system:

Page 4: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 should look exactly like a nondistributed system.”nondistributed system.”

Page 5: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 Hardware independenceindependence

Operating system Operating system independenceindependence

Network independenceNetwork independence DBMS independenceDBMS independence

Page 6: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 7: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 8: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 9: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 10: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 11: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 12: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 13: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 14: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 15: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

Objective 7Objective 7

Distributed Query Distributed Query ProcessingProcessing

A relational distributed system is A relational distributed system is likely to outperform a nonrelational likely to outperform a nonrelational 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 16: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

Example:

Consider Query “Get supplier numbers for London suppliers of red parts”

Database (suppliers-and-parts, simplified):

S {S#, CITY} 10,000 stored tuples at site A

P {P#, COLOR} 100,000 stored tuples at site B

SP {S#, P#} 1,000,000 stored tuples at site A

Assume every stored tuple is 25 bytes(200 bits)long.

Query (“Get supplier numbers for London suppliers of red parts”):

( ( S JOIN SP JOIN P )WHERE CITY = ‘London’ AND

COLOR = COLOR (‘Red’) ) { S# }

Estimated cardinalities of certain intermediate results:

Number of red parts = 10

Number of shipments by London suppliers = 100,000

Communication assumptions:

Data rate = 50,000 bits per second

Access delay = 0.1 second

Page 17: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 = 0.1 + (100000 * 200 ) / 50000

= 400 seconds approx. (6.67minutes)

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

T2 = 0.2 + ( ( 10000 + 1000000 ) * 200 ) / 50000

= 4040 seconds approx. (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 + (10 * 200 ) / 50000

= 0.1 second approx.

Page 18: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 19: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

t1 t4 t5 t6

t2 t3 t7 t8

t9

GETREADY

OK

DO

I

T

DONE

I

T

Coordinator

Participant

Two-phase commit:Force decision

Log entry-end ph.1,start ph.2

“In doubt”

Forces a log entry for agent

Page 20: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 21: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 22: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 23: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

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 24: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

GATEWAYIngres

(SQL)

Oracle

(SQL)

Ingres

database

Oracle

databaseIngres user

Distributed Ingres database

A hypothetical Ingres–provided gateway to Oracle:

Site X Site Y

Page 25: Distributed Databases and Its Twelve Objectives CS157B Name: Yingying Wu Professor: Sin-Min Lee Reference Book: An introduction to Database Systems By.

Thank you!Thank you!