0% found this document useful (0 votes)
21 views27 pages

CH 19

The document discusses distributed databases including homogeneous and heterogeneous systems. It covers topics like distributed data storage through replication and fragmentation. The document also discusses distributed transactions and query processing.

Uploaded by

Bala Krish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views27 pages

CH 19

The document discusses distributed databases including homogeneous and heterogeneous systems. It covers topics like distributed data storage through replication and fragmentation. The document also discusses distributed transactions and query processing.

Uploaded by

Bala Krish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 27

Chapter 19: Distributed Databases

 Heterogeneous and Homogeneous Databases


 Distributed Data Storage
 Distributed Transactions
 Distributed Query Processing

1
Database System Concepts 19.1 ©Silberschatz, Korth and Sudarshan
Distributed Database System

 A distributed database system consists of loosely


coupled sites that share no physical component
 Database systems that run on each site are
independent of each other
 Transactions may access data at one or more sites

2
Database System Concepts 19.2 ©Silberschatz, Korth and Sudarshan
Homogeneous 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
 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 softwrae 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
3
Database System Concepts 19.3 ©Silberschatz, Korth and Sudarshan
Distributed 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.

4
Database System Concepts 19.4 ©Silberschatz, Korth and Sudarshan
Data 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.

5
Database System Concepts 19.5 ©Silberschatz, Korth and Sudarshan
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.
 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
6
Database System Concepts 19.6 ©Silberschatz, Korth and Sudarshan
Data 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)
7
Database System Concepts 19.7 ©Silberschatz, Korth and Sudarshan
Horizontal Fragmentation of account
Relation

branch-name account-number balance

Hillside A-305 500


Hillside A-226 336
Hillside A-155 62

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

branch-name account-number balance

Valleyview A-177 205


Valleyview A-402 10000
Valleyview A-408 1123
Valleyview A-639 750

account2=branch-name=“Valleyview”(account)
8
Database System Concepts 19.8 ©Silberschatz, Korth and Sudarshan
Vertical Fragmentation of employee-info
Relation

branch-name customer-name tuple-id


Hillside Lowman 1
Hillside Camp 2
Valleyview Camp 3
Valleyview Kahn 4
Hillside Kahn 5
Valleyview Kahn 6
Valleyview Green 7
deposit1=branch-name, customer-name, tuple-id(employee-info)
account number balance tuple-id
A-305 500 1
A-226 336 2
A-177 205 3
A-402 10000 4
A-155 62 5
A-408 1123 6
A-639 750 7
deposit2=account-number, balance, tuple-id(employee-info) 9
Database System Concepts 19.9 ©Silberschatz, Korth and Sudarshan
Advantages 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.

10
Database System Concepts 19.10 ©Silberschatz, Korth and Sudarshan
Data Transparency
 Data transparency: Degree to which system user
may remain unaware of the details of how and where
the data items are stored in a distributed system
 Consider transparency issues in relation to:
 Fragmentation transparency
 Replication transparency
 Location transparency

11
Database System Concepts 19.11 ©Silberschatz, Korth and Sudarshan
Naming of Data Items - Criteria

1. Every data item must have a system-wide unique


name.
2. It should be possible to find the location of data
items efficiently.
3. It should be possible to change the location of data
items transparently.
4. Each site should be able to create new data items
autonomously.

12
Database System Concepts 19.12 ©Silberschatz, Korth and Sudarshan
Centralized Scheme - Name Server

 Structure:
 name server assigns all names
 each site maintains a record of local data items
 sites ask name server to locate non-local data items
 Advantages:
 satisfies naming criteria 1-3
 Disadvantages:
 does not satisfy naming criterion 4
 name server is a potential performance bottleneck
 name server is a single point of failure

13
Database System Concepts 19.13 ©Silberschatz, Korth and Sudarshan
Use of Aliases

 Alternative to centralized scheme: each site prefixes


its own site identifier to any name that it generates
i.e., site 17.account.
 Fulfills having a unique identifier, and avoids problems
associated with central control.
 However, fails to achieve network transparency.
 Solution: Create a set of aliases for data items; Store
the mapping of aliases to the real names at each site.
 The user can be unaware of the physical location of a
data item, and is unaffected if the data item is moved
from one site to another.

14
Database System Concepts 19.14 ©Silberschatz, Korth and Sudarshan
Distributed Transactions

Copyright: Silberschatz, Korth and 15


Sudarhan
Distributed Transactions

 Transaction may access data at several sites.


 Each site has a local transaction manager responsible for:
 Maintaining a log for recovery purposes
 Participating in coordinating the concurrent execution of the
transactions executing at that site.
 Each site has a transaction coordinator, which is
responsible for:
 Starting the execution of transactions that originate at the site.
 Distributing subtransactions at appropriate sites for execution.
 Coordinating the termination of each transaction that originates
at the site, which may result in the transaction being committed
at all sites or aborted at all sites.

16
Database System Concepts 19.16 ©Silberschatz, Korth and Sudarshan
Transaction System Architecture

17
Database System Concepts 19.17 ©Silberschatz, Korth and Sudarshan
System Failure Modes

 Failures unique to distributed systems:


 Failure of a site.
 Loss of massages
 Handled by network transmission control protocols
such as TCP-IP
 Failure of a communication link
 Handled by network protocols, by routing messages
via alternative links
 Network partition
 A network is said to be partitioned when it has been
split into two or more subsystems that lack any
connection between them
– Note: a subsystem may consist of a single node
 Network partitioning and site failures are generally
indistinguishable.
18
Database System Concepts 19.18 ©Silberschatz, Korth and Sudarshan
Distributed Query Processing

Copyright: Silberschatz, Korth and 19


Sudarhan
Distributed Query Processing

 For centralized systems, the primary criterion for


measuring the cost of a particular strategy is the
number of disk accesses.
 In a distributed system, other issues must be taken
into account:
 The cost of a data transmission over the network.
 The potential gain in performance from having several
sites process parts of the query in parallel.

20
Database System Concepts 19.20 ©Silberschatz, Korth and Sudarshan
Query Transformation

 Translating algebraic queries on fragments.


 It must be possible to construct relation r from its fragments
 Replace relation r by the expression to construct relation r
from its fragments
 Consider the horizontal fragmentation of the account
relation into
account1 =  branch-name = “Hillside” (account)
account2 =  branch-name = “Valleyview” (account)

 The query  branch-name = “Hillside” (account) becomes

 branch-name = “Hillside” (account1  account2)

which is optimized into


 branch-name = “Hillside” (account1)   branch-name = “Hillside”
(account2)

21
Database System Concepts 19.21 ©Silberschatz, Korth and Sudarshan
Example Query (Cont.)

 Since account has only tuples pertaining to the Hillside


1
branch, we can eliminate the selection operation.
 Apply the definition of account to obtain
2

 branch-name = “Hillside” ( branch-name = “Valleyview”


(account)
 This expression is the empty set regardless of the
contents of the account relation.
 Final strategy is for the Hillside site to return account
1
as the result of the query.

22
Database System Concepts 19.22 ©Silberschatz, Korth and Sudarshan
Simple Join Processing

 Consider the following relational algebra


expression in which the three relations are neither
replicated nor fragmented
account depositor branch
 account is stored at site S1

 depositor at S2

 branch at S3

 For a query issued at site SI, the system needs to


produce the result at site SI

23
Database System Concepts 19.23 ©Silberschatz, Korth and Sudarshan
Possible Query Processing
Strategies

 Ship copies of all three relations to site SI and


choose a strategy for processing the entire locally
at site SI.
 Ship a copy of the account relation to site S2 and
compute temp1 = account depositor at S2. Ship
temp1 from S2 to S3, and compute temp2 = temp1
branch at S3. Ship the result temp2 to SI.
 Devise similar strategies, exchanging the roles S1,
S2, S3
 Must consider following factors:
 amount of data being shipped
 cost of transmitting a data block between sites
 relative processing speed at each site
24
Database System Concepts 19.24 ©Silberschatz, Korth and Sudarshan
Semijoin Strategy
 Let r1 be a relation with schema R1 stores at site S1

Let r2 be a relation with schema R2 stores at site S2


 Evaluate the expression r r2 and obtain the result at
1
S1.
1. Compute temp1  R1  R2 (r1) at S1.
 2. Ship temp from S to S .
1 1 2

 3. Compute temp2  r2 temp1 at S2


 4. Ship temp2 from S2 to S1.

 5. Compute r1 temp2 at S1. This is the same as r1 r2.

25
Database System Concepts 19.25 ©Silberschatz, Korth and Sudarshan
Formal Definition
 The semijoin of r1 with r2, is denoted by:

r1 r2
 it is defined by:
 R1 (r1 r2)
 Thus, r1 r2 selects those tuples of r1 that contributed to
r1 r2.
 In step 3 above, temp2=r2 r1.
 For joins of several relations, the above strategy can be
extended to a series of semijoin steps.

26
Database System Concepts 19.26 ©Silberschatz, Korth and Sudarshan
Join Strategies that Exploit Parallelism

 Consider r1 r2 r3 r4 where relation ri is stored at


site Si. The result must be presented at site S1.
 r1 is shipped to S2 and r1 r2 is computed at S2:
simultaneously r3 is shipped to S4 and r3 r4 is computed
at S4
 S2 ships tuples of (r1 r2) to S1 as they produced;
S4 ships tuples of (r3 r4) to S1
 Once tuples of (r1 r2) and (r3 r4) arrive at S1 (r1 r2)
(r3 r4) is computed in parallel with the computation of
(r1 r2) at S2 and the computation of (r3 r4) at S4.

27
Database System Concepts 19.27 ©Silberschatz, Korth and Sudarshan

You might also like