3 Distribution Design
3 Distribution Design
Introduction
Background
Distributed Database Design
Fragmentation
Data distribution
Database Integration
Semantic Data Control
Distributed Query Processing
Multidatabase Query Processing
Distributed Transaction Management
Data Replication
Parallel Database Systems
Distributed Object DBMS
Peer-to-Peer Data Management
Web Data Management
Current Issues
Design Problem
• No sharing: Each application and its data execute at one site, and there
is no communication with any other program or access to any data file
at other sites. This characterizes the very early days of networking and
is probably not very common today.
• Level of data sharing: All the programs are replicated at all the sites,
but data files are not. Accordingly, user requests are handled at the
site where they originate and the necessary data files are moved around
the network.
It is easier to plan for and manage the static environments than would
be the case for dynamic distributed systems.
Level of knowledge
One possibility, is that the designers do not have any information about
how users will access the database.
The more practical alternatives are that the designers have complete
information, where the access patterns can reasonably be predicted and
do not deviate significantly from these predictions, or partial
information, where there are deviations from the predictions.
Distribution Design
Top-down
mostly in designing systems from scratch
Bottom-up
when the databases already exist at a number of sites
Top-Down Design
Top-Down Design
Requirements analysis
How to fragment?
How to allocate?
Information requirements?
Fragmentation
PROJ
PNO PNAME BUDGET
Figure 3.3
Example
Transparent Access
SELECT ENAME,SAL
Tokyo
FROM EMP,ASG,PAY
WHERE DUR > 12 Paris
Boston
AND EMP.ENO = ASG.ENO Paris projects
AND PAY.TITLE = EMP.TITLE Paris employees
Communication Paris assignments
Network Boston employees
Boston projects
Boston employees
Boston assignments
Montreal
New
Montreal projects
York Paris projects
Boston projects New York projects
New York employees with budget > 200000
New York projects Montreal employees
New York assignments Montreal assignments
Fragmentation Alternatives – Horizontal
PROJ
PROJ1 : projects with budgets less than PNO PNAME BUDGET LOC
$200,000
P1 Instrumentation 150000 Montreal
PROJ2 : projects with budgets greater than P2 Database Develop. 135000 New York
P3 CAD/CAM 250000 New York
or equal to $200,000 P4 Maintenance 310000 Paris
P5 CAD/CAM 500000 Boston
PROJ1 PROJ2
PROJ1 PROJ2
PNO BUDGET PNO PNAME LOC
tuples relations
or
attributes
Completeness
Decomposition of relation R into fragments R1, R2, ..., Rn is
complete if and only if each data item in R can also be
found in some Ri
Reconstruction
If relation R is decomposed into fragments R1, R2, ..., Rn,
then there should exist some relational operator ∇ such
that
R = ∇1≤i≤nRi
Disjointness
If relation R is decomposed into fragments R1, R2, ..., Rn,
and data item di is in Rj, then di should not be in any other
fragment Rk (k ≠ j ).
Allocation Alternatives
Non-replicated
partitioned : each fragment resides at only one site
Replicated
fully replicated : each fragment at each site
partially replicated : each fragment at some of the sites
Rule of thumb:
If read-only queries << 1, replication is advantageous,
update queries
otherwise replication may cause problems
Comparison of Replication Alternatives
Full-replication Partial-replication Partitioning
CONCURRENCY
Moderate Difficult Easy
CONTROL
Possible Possible
REALITY Realistic
application application
Information Requirements
Four categories:
Database information
Application information
Communication network information
Computer system information
Fragmentation
SKILL
TITLE, SAL
L1
EMP PROJ
ENO, ENAME, TITLE PNO, PNAME, BUDGET,
LOC
ASG
ENO, PNO, RESP, DUR
pj : Ai θValue
where θ {=,<,≤,>,≥,≠}, Value Di and Di is the domain of Ai.
For relation R we define Pr = {p1, p2, …,pm}
Example :
PNAME = "Maintenance"
BUDGET ≤ 200000
minterm predicates : Given R and Pr = {p1, p2, …,pm}
define M = {m1,m2,…,mr} as
Example
Definition :
Rj = Fj(R), 1 ≤ j ≤ w
where Fj is a selection formula, which is (preferably) a minterm
predicate.
Therefore,
A horizontal fragment Ri of relation R consists of all the tuples of R
which satisfy a minterm predicate mi.
Given a set of minterm predicates M, there are as many horizontal
fragments of relation R as there are minterm predicates.
Set of horizontal fragments also referred to as minterm fragments.
PHF – Algorithm
Preliminaries :
Pr should be complete
Pr should be minimal
Example
We assume that the non-negativity of the BUDGET values is a feature of the relation that is enforced by an
integrity constraint. Otherwise, a simple predicate of the form 0 BUDGET also needs to be included in Pr
Example :
Assume PROJ[PNO,PNAME,BUDGET,LOC] has two applications defined on it.
Find the budgets of projects at each location. (1)
Find projects with budgets less than $200000. (2)
Completeness of Simple Predicates
According to (1),
Pr={LOC=“Montreal”,LOC=“New York”,LOC=“Paris”}
which is complete.
Minimality of Simple Predicates
card( fi ) card( f j )
Minimality of Simple Predicates
Example :
Pr ={LOC=“Montreal”,LOC=“New York”, LOC=“Paris”,
BUDGET≤200000,BUDGET>200000}
PAY1 PAY2
TITLE SAL TITLE SAL
Mech. Eng. 27000 Elect. Eng. 40000
Programmer 24000 Syst. Anal. 34000
PHF – Example
Fragmentation of relation PROJ
Applications:
Find the name and budget of projects given their no.
Issued at three sites
Access project information according to budget
one site accesses ≤200000 other accesses
>200000
Simple predicates
For application (1)
p1 : LOC = “Montreal”
p2 : LOC = “New York”
p3 : LOC = “Paris”
For application (2)
p4 : BUDGET ≤ 200000
p5 : BUDGET > 200000
Pr = Pr' = {p1,p2,p3,p4,p5}
PHF – Example
PROJ1 PROJ2
PROJ4 PROJ6
Reconstruction
If relation R is fragmented into FR = {R1,R2,…,Rr}
R = Ri FR Ri
Disjointness
Minterm predicates that form the basis of fragmentation should be
mutually exclusive.
Derived Horizontal Fragmentation
SKILL
TITLE, SAL
L1
EMP PROJ
ENO, ENAME, TITLE PNO, PNAME, BUDGET, LOC
L2 L3
ASG
ENO, PNO, RESP, DUR
DHF – Definition
Given a link L where owner(L)=S and member(L)=R, the derived horizontal
fragments of R are defined as
Ri = R ⋉F Si, 1≤i≤w
where w is the maximum number of fragments that will be defined on R
and
Si = Fi (S)
where Fi is the formula according to which the primary horizontal
fragment Si is defined.
DHF – Example
Given link L1 where owner(L1)=PAY and member(L1)=EMP
EMP1 = EMP ⋉ PAY1
EMP1 EMP2
ENO ENAME TITLE ENO ENAME TITLE
Given relation PAY as in Figure 3.3, let p1: SAL < 30000 and
p2: SAL ≥ 3000 be two simple predicates. Perform a
horizontal fragmentation of PAY with respect to these
predicates to obtain PAY1, and PAY2. Using the fragmentation
of PAY, perform further derived horizontal fragmentation for
EMP. Show completeness, reconstruction, and disjointness of
the fragmentation of EMP.
Exercises-Solution
Exercises-Solution
Vertical Fragmentation
Has been studied within the centralized context
design methodology
physical clustering
More difficult than horizontal, because more
alternatives exist.
Two approaches :
grouping
attributes to fragments
splitting
relation to fragments
Vertical Fragmentation
Overlapping fragments
grouping
Non-overlapping fragments
splitting
We do not consider the replicated key attributes to
be overlapping.
Advantage:
Easier to enforce functional dependencies
(for integrity checking etc.)
VF – Information Requirements
Application Information
Attribute affinities
a measure that indicates how closely related the attributes are
This is obtained from more primitive usage data
Attribute usage values
Given a set of queries Q = {q1, q2,…, qq} that will run on the relation
R[A1, A2,…, An],
A1 A2 A3 A4
q1 1 0 1 0
q2 0 1 1 0
q3 0 1 0 1
q4 0 0 1 1
VF – Affinity Measure aff(Ai,Aj)
The attribute affinity measure between two attributes Ai and Aj of a
relation R[A1, A2, …, An] with respect to the set of applications Q = (q1, q2,
…, qq) is defined as follows :
access
query access = access frequency of a query
execution
all sites
VF – Calculation of aff(Ai, Aj)
Then A1 A2 A3 A4
aff(A1, A3) = 15*1 + 20*1+10*1 A1 45 0 45 0
= 45 A2 0 80 5 75
and the attribute affinity matrix AA is A3 45 5 53 3
A4 0 75 3 78
VF – Clustering Algorithm
AM = i j
(affinity of Ai and Aj with their neighbors)
Bond Energy Algorithm
Input: The AA matrix
Output: The clustered affinity matrix CA which is a perturbation of AA
Initialization: Place and fix one of the columns of AA in CA.
Iteration: Place the remaining n-i columns in the remaining i+1
positions in the CA matrix. For each column, choose the placement
that makes the most contribution to the global affinity measure.
Row order: Order the rows according to the column ordering.
Bond Energy Algorithm (detail)
Bond Energy Algorithm
n
where
bond(Ax,Ay) =
z =1
aff(Az,Ax)aff(Az,Ay)
BEA – Example
Consider the following 4 queries for relation PROJ
q1: SELECT BUDGET q2: SELECT PNAME,BUDGET
FROM PROJ FROM PROJ
WHERE PNO=Value
q3: SELECT PNAME q4: SELECT SUM(BUDGET)
FROM PROJ FROM PROJ
WHERE LOC=Value WHERE LOC=Value
Let A1= PNO, A2= PNAME, A3= BUDGET, A4= LOC
A1 A2 A3 A4
q1 1 0 1 0
q2 0 1 1 0
q3 0 1 0 1
q4 0 0 1 1
BEA – Example
Ordering (0-3-1) :
cont(A0,A3,A1) = 2bond(A0 , A3)+2bond(A3 , A1)–2bond(A0 , A1)
= 2* 0 + 2* 4410 – 2*0 = 8820
Ordering (1-3-2) :
cont(A1,A3,A2) = 2bond(A1 , A3)+2bond(A3 , A2)–2bond(A1,A2)
= 2* 4410 + 2* 890 – 2*225 = 10150
Ordering (2-3-4) :
cont (A2,A3,A4) = 1780
BEA – Example
A1 A3 A 2
Therefore, the CA matrix has the form
45 45 0
0 5 80
45 53 5
0 3 75
A3 45 53 5 3
A2 0 5 80 75
A4 0 3 75 78
BEA – Example
BEA – Example
Note: Although, as noted in the book, it doesn’t make sense to compute the
diagonal values in the AA matrix, we show them here since they are used in the
following calculations.
Now we start applying the BEA algorithm. We first fix the first two columns and
the Clustered Affinity (CA) Matrix looks like the following:
BEA – Example
Next we consider placing A3 – there are three places where it can be placed:
(a) to the left of A1, which has a contribution of 16950;
(b) in between A1 and A2, which has a contribution of 22050, and
(c) to the right of A2, which has a contribution of 21450.
Thus, the bets ordering is A1, A3, A2 resulting in the following CA matrix:
VF – Algorithm
How can you divide a set of clustered attributes {A1, A2, …, An} into
two (or more) sets {A1, A2, …, Ai} and {Ai, …, An} such that there are no
(or minimal) applications that access both (or more than one) of the
sets.
A1 A2 A3 … Ai Ai+1 . . A
. m
A1
A2
TA
Ai
Ai+1
BA
Am
VF – ALgorithm
Define
TQ = set of applications that access only TA
BQ = set of applications that access only BA
OQ = set of applications that access both TA and BA
and
CTQ = total number of accesses to attributes by applications that access only TA
CBQ = total number of accesses to attributes by applications that access only BA
COQ = total number of accesses to attributes by applications that access both TA and BA
Then find the point along the diagonal that maximizes
CTQCBQCOQ2
VF – Algorithm
Two problems :
Cluster forming in the middle of the CA matrix
Shift a row up and a column left and apply the algorithm to find the “best”
partitioning point
Do this for all possible shifts
Cost O(m2)
More than two clusters
m-way partitioning
try 1, 2, …, m–1 split points along diagonal and try to find the best point for
each of these
Cost O(2m)
VF – Correctness
A relation R, defined over attribute set A and key K, generates the vertical
partitioning FR = {R1, R2, …, Rr}.
Completeness
The following should be true for A:
A= ARi
Reconstruction
Reconstruction can be achieved by
R= ⋈•
K Ri, Ri FR
Disjointness
TID's are not considered to be overlapping since they are maintained by the system
Duplicated keys are not considered to be overlapping
Hybrid Fragmentation
Decision Variable
Total Cost
query processing cost
all queries
cost
(no. of update accesses+ no. of read accesses)
Access cost
all sites all fragments
xij local processing cost at a site
Cost of updates
update message cost
all sites all fragments
acknowledgment cost
all sites all fragments
Retrieval Cost
min all sites (cost of retrieval command
all fragments cost of sending back the result)
Allocation Model
Constraints
Response Time
execution time of query ≤ max. allowable response time for that
query
Storage Constraint
storage(for a site)
requirement of a fragment at that site
storage capacity at that site
all fragments
Solution Methods
FAP is NP-complete
DAP also NP-complete
Heuristics based on
single commodity warehouse location (for FAP)
knapsack problem
branch and bound techniques
network flow
Allocation Model