2 DistDesign
2 DistDesign
Design Problem
Page 1
Distribution Design
n Top-down
l mostly in designing systems from scratch
n Bottom-up
l when the databases already exist at a number of sites
Top-Down Design
Requirements
Analysis
Objectives
User Input
Conceptual View Integration View Design
Design
Access
GCS Information ES’s
Distribution
Design User Input
LCS’s
Physical
Design
LIS’s
Page 2
Distribution Design Issues
How to fragment?
How to allocate?
Information requirements?
Fragmentation
n Can't we just distribute relations?
n What is a reasonable unit of distribution?
l Relation
u Views are subsets of relations è locality
u Extra communication
l Fragments of relations (sub-relations)
u Concurrent execution of a number of transactions that
access different portions of a relation
u Views that cannot be defined on a single fragment will
require extra processing
u Semantic data control (especially integrity
enforcement) more difficult
Page 3
Fragmentation Alternatives –
Horizontal
PROJ"
PROJ1 : projects with budgets PNO" PNAME" BUDGET" LOC"
$200,000
PROJ1" PROJ2"
Fragmentation Alternatives –
Vertical
PROJ"
PROJ1: information about PNO" PNAME" BUDGET" LOC"
locations
PROJ1" PROJ2"
Page 4
Degree of Fragmentation
tuples relations
or
attributes
Correctness of Fragmentation
n Completeness
l 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
n Reconstruction
l If relation R is decomposed into fragments R1, R2, ..., Rn,
then there should exist some relational operator∇such
that
R = ∇1≤i≤nRi
n Disjointness
l 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 ).
Page 5
Allocation Alternatives
n Non-replicated
l partitioned : each fragment resides at only one site
n Replicated
l fully replicated : each fragment at each site
l partially replicated : each fragment at some of the sites
n Rule of thumb:
read-only queries
If ≥ 1 replication is advantageous,
update quries
otherwise replication may cause problems
Information Requirements
n Four categories:
l Database information
l Application information
l Communication network information
l Computer system information
Page 6
Fragmentation
TITLE,"SAL"
L 1"
EMP" PROJ"
L 2" L 3"
ASG"
Page 7
PHF - Information Requirements
n Application Information
l simple predicates : Given R[A1, A2, …, An], a simple predicate pj
is
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
l minterm predicates : Given R and Pr = {p1, p2, …,pm}
define M = {m1,m2,…,mr} as
Page 8
PHF – Information Requirements
n Application information.
l minterm selectivities: sel(mi).
u The number of tuples of the relation that would
be accessed by a user query which is specified
according to a given minterm predicate mi.
l access frequencies: acc(qi).
u The frequency with which a user application qi
accesses data.
u Access frequency for a minterm predicate can
also be defined.
Page 9
PHF – Algorithm
Given: A relation R, the set of simple predicates Pr
Output: The set of fragments of R, FR = {R1, R2,
…,Rw} that obey the fragmentation rules.
Preliminaries :
l Pr should be complete
l Pr should be minimal
Page 10
Completeness of Simple Predicates
According to (1),
Pr={LOC=“Montreal”,LOC=“New York”,LOC=“Paris”}
which is not complete with respect to (2).
Modify
Pr ={LOC=“Montreal”,LOC=“New York”,LOC=“Paris”,
BUDGET≤200000,BUDGET>200000}
which is complete.
Page 11
Minimality of Simple Predicates
Example :
Pr ={LOC=“Montreal”,LOC=“New York”, LOC=“Paris”,
BUDGET≤200000,BUDGET>200000}
COM_MIN Algorithm
Given: a relation R and a set of simple
predicates Pr
Output: a complete and minimal set of simple
predicates Pr' for Pr
Page 12
COM_MIN Algorithm
Initialization :
● find a pi ∈Pr such that pi partitions R according to Rule 1
● set Pr' = pi ; Pr ← Pr – pi ; F ←fi
PHORIZONTAL Algorithm
Makes use of COM_MIN to perform fragmentation.
Input: a relation R and a set of simple
predicates Pr
Output: a set of minterm predicates M according
to which relation R is to be fragmented
Page 13
PHF – Example
n Two candidate relations : PAY and PROJ.
n Fragmentation of relation PROJ
l Applications:
u Find the name and budget of projects given their location
s Issued at three sites
u Access project information according to budget
s one site accesses <200000 other accesses ≥200000
l Simple predicates
l For application (1)
p1 : LOC = “Montreal”
p2 : LOC = “New York”
p3 : LOC = “Paris”
l For application (2)
p4 : BUDGET ≤ 200000
p5 : BUDGET > 200000
l Pr = Pr' = {p1,p2,p3,p4,p5}
PHF – Example
n Fragmentation of relation PROJ continued
l Minterm fragments left after elimination
m1 : (LOC = “Montreal”) ∧ (BUDGET ≤ 200000)
Page 14
PHF – Example
PROJ1" PROJ2"
Database"
P1" Instrumentation" 150000" Montreal" P2" 135000" New York"
Develop."
PROJ4" PROJ6"
PHF – Correctness
n Completeness
l Since Pr' is complete and minimal, the selection predicates are
complete
n Reconstruction
l If relation R is fragmented into FR = {R1,R2,…,Rr}
R = ∪∀Ri ∈FR Ri
n Disjointness
l Minterm predicates that form the basis of fragmentation should be
mutually exclusive.
Page 15
Vertical Fragmentation
n Has been studied within the centralized
context
l design methodology
l physical clustering
Vertical Fragmentation
n Overlapping fragments
l grouping
n Non-overlapping fragments
l splitting
Page 16
VF – Information Requirements
n Application Information
l Attribute affinities
u a measure that indicates how closely related the attributes are
u This is obtained from more primitive usage data
l Attribute usage values
u Given a set of queries Q = {q1, q2,…, qq} that will run on the
relation R[A1, A2,…, An],
⎧
1 if attribute Aj is referenced by query qi
use(qi,Aj) = ⎨
⎩
0 otherwise
VF – Definition of use(qi,Aj)
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
CS742 – Distributed & Parallel DBMS M. Tamer Özsu Page 2. 34
Page 17
VF – Affinity Measure aff(Ai,Aj)
access
query access =
∑
access frequency of a query *
execution
all sites
Page 18
VF – Clustering Algorithm
n Take the attribute affinity matrix AA and
reorganize the attribute orders to form clusters
where the attributes in each cluster
demonstrate high affinity to one another.
n Bond Energy Algorithm (BEA) has been used
for clustering of entities. BEA finds an
ordering of entities (in our case attributes)
such that the global affinity measure is
maximized.
AM =
∑
∑
i j
(affinity of Ai and Aj with their neighbors)
Page 19
Bond Energy Algorithm
“Best” placement? Define contribution of a
placement:
where n
bond(Ax,Ay) = ∑
aff(A ,A )aff(A ,A )
z =1
z x z y
BEA – Example
Consider the following AA matrix and the corresponding CA matrix
where A1 and A2 have been placed. Place A3:
A1 A2 A3 A4 A1 A2
A 1 45 0 5 0 45 0
A 2 0 80 5 75 0 80
AA = CA =
A 3 45 5 53 3 45 5
A 4 0 75 3 78 0 75
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
Page 20
BEA – Example
n Therefore, the CA matrix has the form A1 A3 A2
45 45 0
0 5 80
45 53 5
0 3 75
n When A is placed, the final form of the CA matrix
4
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 . . .Am
A1
A2
TA
...
Ai
Ai+1
BA
...
Am
Page 21
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
CTQ*CBQ-COQ2
VF – Algorithm
Two problems :
Cluster forming in the middle of the CA matrix
l Shift a row up and a column left and apply the algorithm to
find the “best” partitioning point
l Do this for all possible shifts
l Cost O(m2)
Page 22
VF – Correctness
A relation R, defined over attribute set A and key K,
generates the vertical partitioning FR = {R1, R2, …, Rr}.
n Completeness
l The following should be true for A:
A = ∪ AR i
n Reconstruction
l Reconstruction can be achieved by
R = ⋈K Ri, ∀Ri ∈ FR
n Disjointness
l TID's are not considered to be overlapping since they are maintained
by the system
l Duplicated keys are not considered to be overlapping
CS742 – Distributed & Parallel DBMS M. Tamer Özsu Page 2. 45
Fragment Allocation
n Problem Statement
Given
F = {F1, F2, …, Fn} fragments
S ={S1, S2, …, Sm} network sites
Q = {q1, q2,…, qq} applications
Find the "optimal" distribution of F to S.
n Optimality
l Minimal cost
u Communication + storage + processing (read & update)
u Cost in terms of time (usually)
l Performance
Response time and/or throughput
l Constraints
u Per site constraints (storage & processing)
Page 23
Information Requirements
n Database information
l selectivity of fragments
l size of a fragment
n Application information
l access types and numbers
l access localities
Allocation Model
General Form
min(Total Cost)
subject to
response time constraint
storage constraint
processing constraint
Decision Variable
Page 24
Allocation Model
n Total Cost
∑
query processing cost +
all queries
∑
∑
cost of storing a fragment at a site
all sites all fragments
Page 25