distributed databases

57
SUSHIL SUSHIL KULKARNI KULKARNI DISTRIBUTED DISTRIBUTED DBMS DBMS

Upload: sushil-kulkarni

Post on 14-Nov-2014

5 views

Category:

Documents


1 download

DESCRIPTION

This gives the idea of distributed databases and its related concepts

TRANSCRIPT

Page 1: Distributed databases

SUSHIL SUSHIL

KULKARNIKULKARNI

DISTRIBUTED DISTRIBUTED DBMSDBMS

Page 2: Distributed databases

DDBMS ConceptsDDBMS Concepts ApplicationsApplications Characteristics, Properties of DDBMSCharacteristics, Properties of DDBMS Distributed ProcessingDistributed Processing Advantages & Disadvantages DDBMSAdvantages & Disadvantages DDBMS Types & Functions of DDBMSTypes & Functions of DDBMS Main Issues of DDBMSMain Issues of DDBMS Component Architecture for DDBMSComponent Architecture for DDBMS Data Allocation & FragmentationData Allocation & Fragmentation TransparenciesTransparencies

Page 3: Distributed databases

CONCEPTSCONCEPTS

Page 4: Distributed databases

CONCEPTSCONCEPTSCONCEPTSCONCEPTS• So far, we assume a centralized database

Data are stored in one location (e.g. a single

hard disk) A centralized database management system to

handle transaction To handle multiple requests, a client-server

system is used

- Client send requests for data to server

- Server handle query, transaction management etc.

SUSHIL KULKARNISUSHIL KULKARNI

Page 5: Distributed databases

• This is not the only possibility• In many cases, it may be advantageous

for data to be distributed– Branches of a bank– Different part of the government storing

different kind of data about a person– Different organizations sharing part of their

data

• Thus, distributed databases

CONCEPTSCONCEPTSCONCEPTSCONCEPTS

SUSHIL KULKARNISUSHIL KULKARNI

Page 6: Distributed databases

• Data spread over multiple machines (also referred to as sites or nodes.

• Network interconnects the machines• Data shared by users on multiple machines

CONCEPTSCONCEPTSCONCEPTSCONCEPTS

SUSHIL KULKARNISUSHIL KULKARNI

Page 7: Distributed databases

CONCEPTSCONCEPTSCONCEPTSCONCEPTS

Distributed database

Logical interrelated collection of shared data, along with description of data, physically distributed over a computer network.

SUSHIL KULKARNISUSHIL KULKARNI

Page 8: Distributed databases

CONCEPTSCONCEPTSCONCEPTSCONCEPTS

Distributed DBMS

The software system that permits the management of the distributed database and makes the distribution transparent to users

SUSHIL KULKARNISUSHIL KULKARNI

Page 9: Distributed databases

CONCEPTSCONCEPTSCONCEPTSCONCEPTS

Applications

• User access distributed database via

applications

SUSHIL KULKARNISUSHIL KULKARNI

Page 10: Distributed databases

CONCEPTSCONCEPTSCONCEPTSCONCEPTS

TWO types of Applications

• Local application : Application that do not

required data from other sites.

• Global application : Application that required

data from other sites.

SUSHIL KULKARNISUSHIL KULKARNI

Page 11: Distributed databases

• In a homogeneous distributed database:

– All sites have identical software.– Are aware of each other and agree to

cooperate in processing user requests.– Each site surrenders part of its autonomy

in terms of right to change schemas or software.

– Appears to user as a single system.

TYPES OF DDBMSTYPES OF DDBMSTYPES OF DDBMSTYPES OF DDBMS

SUSHIL KULKARNISUSHIL KULKARNI

Page 12: Distributed databases

• In a heterogeneous distributed database:

– Different sites may use different schemas and software.• Difference in schema is a major problem for

query processing.• Difference in software is a major problem for

transaction processing.– Sites may not be aware of each other and may

provide only limited facilities for cooperation in

transaction processing.

TYPES OF DDBMSTYPES OF DDBMSTYPES OF DDBMSTYPES OF DDBMS

SUSHIL KULKARNISUSHIL KULKARNI

Page 13: Distributed databases

Identical DBMSs

TYPE: HOMOGENEOUS DBMSTYPE: HOMOGENEOUS DBMSTYPE: HOMOGENEOUS DBMSTYPE: HOMOGENEOUS DBMS

SUSHIL KULKARNISUSHIL KULKARNI

Page 14: Distributed databases

Non-identical DBMSs

TYPE: HETROGENEOUS DBMSTYPE: HETROGENEOUS DBMSTYPE: HETROGENEOUS DBMSTYPE: HETROGENEOUS DBMS

SUSHIL KULKARNISUSHIL KULKARNI

Page 15: Distributed databases

• Location Transparency – User does not have to know the location of the data.– Data requests automatically forwarded to appropriate

sites

• Local Autonomy – Local site can operate with its database when

network connections fail– Each site controls its own data, security,

logging, recovery

OBJECTIVES : DISTRIBUTED OBJECTIVES : DISTRIBUTED ARCHITECTUREARCHITECTURE

OBJECTIVES : DISTRIBUTED OBJECTIVES : DISTRIBUTED ARCHITECTUREARCHITECTURE

SUSHIL KULKARNISUSHIL KULKARNI

Page 16: Distributed databases

Synchronous Distributed Database• All copies of the same

data are always identical

• Data updates are immediately applied to all copies throughout network

• Good for data integrity• High overhead slow

response times

• Asynchronous Distributed Database• Some data inconsistency

is tolerated• Data update propagation

is delayed• Lower data integrity• Less overhead faster

response time

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

SIGNIFICANT TRADE -OFFSIGNIFICANT TRADE -OFFSIGNIFICANT TRADE -OFFSIGNIFICANT TRADE -OFF

Page 17: Distributed databases

Advantages & DisadvantagesAdvantages & Disadvantages

Advantages• Increased reliability

& availability• Local control• Modular growth• Lower

communication costs

• Faster response

Disadvantages• Software cost &

complexity• Processing overhead• Data integrity• Slow response

Page 18: Distributed databases

DISTRIBUTED PROCESSINGDISTRIBUTED PROCESSINGDISTRIBUTED PROCESSINGDISTRIBUTED PROCESSING

A centralized database that can be accessed over a computer network.

SUSHIL KULKARNISUSHIL KULKARNI

Page 19: Distributed databases

DISTRIBUTED PROCESSINGDISTRIBUTED PROCESSINGDISTRIBUTED PROCESSINGDISTRIBUTED PROCESSING

SUSHIL KULKARNISUSHIL KULKARNI

T T T

COM 1

T T T

COM 2

Communication Network

T T T

COM 3

DB

Page 20: Distributed databases

FUNCTIONS OF DDBMSFUNCTIONS OF DDBMSFUNCTIONS OF DDBMSFUNCTIONS OF DDBMSFunctions of a centralized DBMS plus:

extended communication to allow the transfer of

queries and data among sites

extended system catalog to store data distribution

details

distributed query processing , including query

optimization

SUSHIL KULKARNISUSHIL KULKARNI

Page 21: Distributed databases

FUNCTIONS OF DDBMSFUNCTIONS OF DDBMSFUNCTIONS OF DDBMSFUNCTIONS OF DDBMS

extended concurrency control to maintain

consistency of replicated data.

extended recovery services to take account

of failures of individual sites and common

links

SUSHIL KULKARNISUSHIL KULKARNI

Page 22: Distributed databases

TWO MAIN ISSUES IN DDBMSTWO MAIN ISSUES IN DDBMSTWO MAIN ISSUES IN DDBMSTWO MAIN ISSUES IN DDBMS

Making query from one site to the same or

remote site.

Logical database is partitioned in to different

data streams and located at different sites.

SUSHIL KULKARNISUSHIL KULKARNI

Page 23: Distributed databases

COMPONENT ARCHITECTURE FOR COMPONENT ARCHITECTURE FOR DDBMSDDBMS

COMPONENT ARCHITECTURE FOR COMPONENT ARCHITECTURE FOR DDBMSDDBMS

• Local DBMS

• Data Communication Component

• Global System Catalog

• Distributed DBMS component

SUSHIL KULKARNISUSHIL KULKARNI

Page 24: Distributed databases

DATA DATA ALLOCATIONALLOCATION

Page 25: Distributed databases

DATA ALLOCATIONDATA ALLOCATIONDATA ALLOCATIONDATA ALLOCATION

• Centralized

• Fragmented

• Complete replication

• Selective replication

SUSHIL KULKARNISUSHIL KULKARNI

Page 26: Distributed databases

Distributed Data StorageDistributed Data Storage

• Assume relational data model.• Replication:

– System maintains multiple copies of data, stored in different sites, for faster retrieval and fault tolerance.

• Fragmentation:– Relation is partitioned into several fragments stored in

distinct sites

• Replication and fragmentation can be combined:– Relation is partitioned into several fragments: System

maintains several identical replicas of each such fragment.

Page 27: Distributed databases

Data ReplicationData Replication

• A relation or fragment of a relation is replicated if it is stored redundantly in two or more sites.

• Full replication of a relation is the case where the relation is stored at all sites.

• Fully redundant databases are those in which every site contains a copy of the entire database.

SUSHIL KULKARNISUSHIL KULKARNI

Page 28: Distributed databases

Data Replication (Cont.)

• Advantages of Replication:– Availability: failure of site containing relation r

does not result in unavailability of r is replicas exist.

– Parallelism: queries on r may be processed by several nodes in parallel.

– Reduced data transfer: relation r is available locally at each site containing a replica of r.

Data ReplicationData Replication

SUSHIL KULKARNISUSHIL KULKARNI

Page 29: Distributed databases

Data Replication (Cont.)

• Disadvantages of Replication– Increased cost of updates: each replica of

relation r must be updated.

– Increased complexity of concurrency control: concurrent updates to distinct replicas may lead to inconsistent data unless special concurrency control mechanisms are implemented.

• One solution: choose one copy as primary copy and apply concurrency control operations on primary copy.

Data ReplicationData Replication

Page 30: Distributed databases

Data FragmentationData Fragmentation

• Division of relation r into fragments r1, r2, …, rn which contain sufficient information to reconstruct relation r.

• Horizontal fragmentation: each tuple of r is assigned to one or more fragments.

• Vertical fragmentation: the schema for relation r is split into several smaller schemas.– All schemas must contain a common candidate key (or superkey)

to ensure lossless join property.– A special attribute, the tuple-id attribute may be added to each

schema to serve as a candidate key.

• Example : relation account with following schema.• Account-schema = (branch-name, account-number,

balance).

Page 31: Distributed databases

-Fragments contain subsets of complete tuples (all attributes at all sites)

How to reconstruct R= Rs1 Rs2 ……. Rsn

HORIZONTAL FRAGMENTATIONHORIZONTAL FRAGMENTATION

Original relation

A1 A2 ………. An1

1

1

2

2

3

3

3

T1T1

T2T2

T3T3

..

.T60.T60

T61T61

..

..

TnTn

A1 A2 ………. An

A1 A2 ………. AnT1

T2

T3

.

.T60

T61

.

.

Tn

Site 1

Site 2

Page 32: Distributed databases

 A1 A2 A3 A4

A1 A2 A3 A4

Original Relation (R) t1

t2

tn

RS1

RS2

t1

t2

tn

t1

t2

tn

SITE1 SITE2

How to Reconstruct:

R=Rs1 Rs2 Rsn

TID –Tuple ID Hidden Attribute to

ensure account and simple join reconstruction

RS1.TID=RS2.TID

Join condition

1

2

n

1

2

n

TID TID

VERTICAL FRAGMENTATIONVERTICAL FRAGMENTATION

Page 33: Distributed databases

 A1 A2 A3 A4

A1 A2 A3 A4

Original Relation (R) t1

t2

tn

RS1

RS2

t1

t2

tn

t1

t2

tn

SITE1 SITE2

How to Reconstruct:

R=Rs1 Rs2 Rsn

TID –Tuple ID Hidden Attribute to

ensure account and simple join reconstruction

RS1.TID=RS2.TID

Join condition

1

2

n

1

2

n

TID TID

VERTICAL FRAGMENTATIONVERTICAL FRAGMENTATION

Page 34: Distributed databases

usa

Europe

A1 A2 A3

A1 A2 A3

A4 A5

A4 A5

A1 A2 A3 A4 A5

(Salary Attributes)

(Benefit Attributes)

Rs1

Rs2

Rs3

Rs4

R

MIXED FRAGMENTATIONMIXED FRAGMENTATION

Page 35: Distributed databases

 A1 A2 A3 A4

A1 A2 A3 A4

Original Relation (R) t1

t2

tn

RS1

RS2

t1

t2

tn

t1

t2

tn

SITE1 SITE2

How to Reconstruct:

R=Rs1 Rs2 Rsn

TID –Tuple ID Hidden Attribute to

ensure account and simple join reconstruction

RS1.TID=RS2.TID

Join condition

1

2

n

1

2

n

TID TID

MIXED FRAGMENTATIONMIXED FRAGMENTATION

Page 36: Distributed databases

Horizontal Fragmentation of Horizontal Fragmentation of accountaccount RelationRelation

branch-name account-number balance

HillsideHillsideHillside

A-305A-226A-155

50033662

account1=branch-name=“Hillside”(account)

branch-name account-number balance

ValleyviewValleyviewValleyviewValleyview

A-177A-402A-408A-639

205100001123750

account2=branch-name=“Valleyview”(account)

SUSHIL KULKARNISUSHIL KULKARNI

Page 37: Distributed databases

branch-name customer-name tuple-id

HillsideHillsideValleyviewValleyviewHillsideValleyviewValleyview

LowmanCampCampKahnKahnKahnGreen

deposit1=branch-name, customer-name, tuple-id(employee-info)

1234567

account number balance tuple-id

50033620510000621123750

1234567

A-305A-226A-177A-402A-155A-408A-639

deposit2=account-number, balance, tuple-id(employee-info)

Vertical Fragmentation of Vertical Fragmentation of employee-info employee-info RelationRelation

Page 38: Distributed databases

Advantages of FragmentationAdvantages of Fragmentation

• Horizontal:– allows parallel processing on fragments of a relation– allows a relation to be split so that tuples are located where

they are most frequently accessed

• Vertical: – allows tuples to be split so that each part of the tuple is stored

where it is most frequently accessed– tuple-id attribute allows efficient joining of vertical fragments– allows parallel processing on a relation

• Vertical and horizontal fragmentation can be mixed.– Fragments may be successively fragmented to an arbitrary

depth.

SUSHIL KULKARNISUSHIL KULKARNI

Page 39: Distributed databases

Partition of Attributes/tuples need not be disjoint

REPLICATION and FRAGMENTATION

A1 A2 A3 A4 A5

A1 A2 A3 A4 A2 A3 A4 A5

Overlap

(replication of attributes)

Page 40: Distributed databases

TRANSPARENCIESTRANSPARENCIES

Page 41: Distributed databases

TRANSPARENCIES IN DDBMSTRANSPARENCIES IN DDBMSTRANSPARENCIES IN DDBMSTRANSPARENCIES IN DDBMS

• Transparencies hide implementation details from the user

• Example in Centralized databases : Data independence

• Main types of transparencies in DDBMS:

o Distributed Transparency

o Transaction Transparency

SUSHIL KULKARNISUSHIL KULKARNI

Page 42: Distributed databases

DISTRIBUTED TRANSPARENCYDISTRIBUTED TRANSPARENCYDISTRIBUTED TRANSPARENCYDISTRIBUTED TRANSPARENCY

Allows the user to see the database as a

single, logical entity.

If this transparency is exhibited then the

user does not need to know that

1. The data are partitioned.

2. Data can be replicated at several

sites.

3. Data location.

SUSHIL KULKARNISUSHIL KULKARNI

Page 43: Distributed databases

EXAMPLEEXAMPLEEXAMPLEEXAMPLE

Staff (staffNo, position, sex, dob, salary,

fName, lName, branchNo)

Vertical fragmentation:

SUSHIL KULKARNISUSHIL KULKARNI

(Staff)dbranchNo,lNamefName,staffNo,Π2S

(Staff)salarydob,,sexposition,staffNo,Π1S

Page 44: Distributed databases

EXAMPLEEXAMPLEEXAMPLEEXAMPLE

Fragment S 2 according to branch number.

Assume that there are only three branches.

Horizontal fragmentation:

SUSHIL KULKARNISUSHIL KULKARNI

(Staff)'007'23

S

(Staff)'005'22

S

(Staff)'003'21

S

BbranchNo

BbranchNo

BbranchNo

Page 45: Distributed databases

EXAMPLEEXAMPLEEXAMPLEEXAMPLE

Assume that :

S 1 and S 2 are at site 5,

S 21 at site 3

S 22 at site 5

S 23 at site 7

SUSHIL KULKARNISUSHIL KULKARNI

Page 46: Distributed databases

FRAGMENTATION TRANSPARENCYFRAGMENTATION TRANSPARENCYFRAGMENTATION TRANSPARENCYFRAGMENTATION TRANSPARENCY

If it is provided then the user does not need

to know the data is fragmented.

Example:

SELECT fName, lName

FROM Staff

WHERE position = ‘ Manager ’

SUSHIL KULKARNISUSHIL KULKARNI

Page 47: Distributed databases

LOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCY

If it is provided then the user must know

how the data has been fragmented but still

does not have know the location of the data.

SUSHIL KULKARNISUSHIL KULKARNI

Page 48: Distributed databases

LOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCY

Example:SELECT fName, lName

FROM S21

WHERE staffNo IN (SELECT staffNO FROM S1 where

position = ‘ Manager ’)

UNION

SELECT fName, lName

FROM S22

WHERE staffNo IN (SELECT staffNO FROM S1 where

position = ‘ Manager ’)SUSHIL KULKARNISUSHIL KULKARNI

Page 49: Distributed databases

LOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCY

Example:

UNION

SELECT fName, lName

FROM S23

WHERE staffNo IN (SELECT staffNO FROM S1 where

position = ‘ Manager ’ )

SUSHIL KULKARNISUSHIL KULKARNI

Page 50: Distributed databases

LOCAL MAPPING TRANSPARENCYLOCAL MAPPING TRANSPARENCYLOCAL MAPPING TRANSPARENCYLOCAL MAPPING TRANSPARENCY

If it is provided then the user must know

how the data has been fragmented as well

as the location of the data.

SUSHIL KULKARNISUSHIL KULKARNI

Page 51: Distributed databases

LOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCY

Example:SELECT fName, lName

FROM S21 AT SITE 3

WHERE staffNo IN (SELECT staffNO FROM S1 AT SITE 5

where position = ‘ Manager ’)

UNION

SELECT fName, lName

FROM S22 AT SITE 5

WHERE staffNo IN (SELECT staffNO FROM S1 AT SITE 3

where position = ‘ Manager ’)SUSHIL KULKARNISUSHIL KULKARNI

Page 52: Distributed databases

LOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCYLOCATION TRANSPARENCY

Example:

UNION

SELECT fName, lName

FROM S23 AT SITE 7

WHERE staffNo IN (SELECT staffNO FROM S1 AT SITE 3

where position = ‘ Manager ’ )

SUSHIL KULKARNISUSHIL KULKARNI

Page 53: Distributed databases

TRANSACTION TRANSPARENCYTRANSACTION TRANSPARENCYTRANSACTION TRANSPARENCYTRANSACTION TRANSPARENCY

It maintains distributed database’s integrity

and consistency.

SUSHIL KULKARNISUSHIL KULKARNI

Page 54: Distributed databases

Issues 1:

Parallel Processing across Fragments

LNameLName((salary>40,000salary>40,000((EmployeeEmployee))))

LNameLName( ( salary>40,000(Emp1))salary>40,000(Emp1)) UU LName( LName( salary>40,000(Emp2))salary>40,000(Emp2))

QUERY PROCESSING IN DDMSQUERY PROCESSING IN DDMS

=Emp1 U Emp2

2 Fragments

Site 1 Site 2

Execution in Parallel on fragments

and union results togetherand union results together

Horizontal Horizontal fragmentationsfragmentations

Page 55: Distributed databases

(A B) C

A (B C)

Site1 Site2 Site3 Joins- symmetric and associative

Parallel Processing

(xx(A)) (B C)

QUERY PROCESSING IN DDMSQUERY PROCESSING IN DDMS

Page 56: Distributed databases

R= Fnames, Cnames, Dnames (Employee Department)

Strategies:

1)Ship both relations to the result site and join there

2)Ship employee to 2, join at 2, results to 3

3)Ship Department to 1, join at 1, results to 3

minimize total communication cost of data transfer

1,003,000 1,003,000 bytes bytes

transferedtransfered1,002,000 1,002,000

bytes bytes transferedtransfered5,000 bytes 5,000 bytes transferedtransfered

Join StrategiesJoin Strategies

Site 3Site 3

100 records, 2000 bytes100 records, 2000 bytes

Site 1Site 1

10,000 records, 10,000 records, 1,000,000 bytes1,000,000 bytes

Site 2Site 2

100 records, 3000 100 records, 3000 bytesbytes

Mg rssn to ssn

QUERY PROCESSING IN DDMSQUERY PROCESSING IN DDMS

Page 57: Distributed databases

THANKS !THANKS !