Professional Documents
Culture Documents
DDS5 Design
DDS5 Design
Dr. M. Alam
Outline
Introduction Design Strategies Distribution Design Issues Fragmentations
Horizontal & Vertical Fragmentation
Allocation
Dr. M. Alam
Design Introduction
In the general setting :
Making decisions about the placement of data and programs across the sites of a computer network as well as possibly designing the network itself.
Level of sharing
Dr. M. Alam Distributed Database Management Systems 4
Level of Sharing
No Sharing
Each application & its data execute at one site. No communication with other programs or access to data at other sites.
Data Sharing
All programs are replicated at all sites but not the data files. User requests are handled at home site only & necessary data files are moved around the network.
Dr. M. Alam
Dr. M. Alam
Level of Knowledge
No Information
Designer has no information how user will access DB.
Complete Information
Access pattern can be predicted that do not deviate significantly from prediction.
Partial Information
Predicted pattern may deviate..
Dr. M. Alam
Dr. M. Alam
Top-down Approach
Requirement Analysis System Requirements (Objectives) Conceptual Design GCS
User Input View Integration
Access In formation Distributed Design Local Conceptual Schemas Physical Design Physical Schema
User Input
Feedback
Dr. M. Alam
Feedback
9
Physical Design: Maps LCS to physical storage devices available at corresponding sites. Access pattern information about fragments is its input. Monitoring: Design & development activity needs constant monitoring & periodic adjustments.
Dr. M. Alam
11
Bottom-up Approach
Suitable for applications where database already exists. Designing task involves integrating these into one database. Starting point is individual conceptual schemas Exists primarily in the context of heterogeneous database
External Schema Global Schema External Schema
Multidatabase Architecture
Dr. M. Alam Distributed Database Management Systems 12
Why fragment at all? How to fragment? How much should be fragmented? How to test correctness? Allocation Strategy Required Information
Dr. M. Alam
13
Fragmentation
Unit of distribution: Relation?
Views are subsets of relations, extra communication. Unnecessary high volume of remote data access or unnecessary replication.
Can't we just distribute relations? Instead of distributing relations, why not divide the relation into sub-relation (fragments) & distribute fragments. Fragments of relations (sub-relations)
Views that cannot be defined on a single fragment will require extra processing Semantic data control (especially integrity enforcement) is more difficult
Dr. M. Alam
14
Dr. M. Alam
15
Fragmentation Alternatives
Horizontal Fragmentation
Partitions a table along its tuples. Performed based on some Predicate / Condition Primary & Derived Horizontal Fragmentation.
Vertical Fragmentation
Different subsets of attributes are stored at different places
Dr. M. Alam
16
Fragmentation : Example
Id 1 2 3 Name Akram Bashir Saleem Sal 10K 15K 20K Dept. D1 D2 D3
Horizontal Fragmentation Rows split : Sal > 15K Id Name 1 Akram 2 Bashir Sal Dept. 10K D1 15K D2
Vertical Fragmentation Columns split : Primary Key Retained Id Name 1 2 3 Akram Bashir Saleem Id Sal 1 10K 2 3 15K 20K Dept. D1 D2 D3
17
PRJ2 P-ID P2 P3 P4 P-Name Flyover Building School Bud 40M 50M 30M LOC Lahore Islamabad Karachi
18
Dr. M. Alam
PRJ
P-ID P1 P2 P3 P4 P-Name Bridge Flyover Building School PRJ2 Bud 20M 40M 50M 30M LOC Karachi Lahore Islamabad Karachi
P-ID P1 P2 P3 P4
Distributed Database Management Systems
Degree of Fragmentation
Finite number of alternatives
Tuples or Attributes
Relations
Finding the suitable level of partitioning within this range, Between no to the extreme level that could be to the individual tuple or column fragmentation; a compromised decision.
Dr. M. Alam Distributed Database Management Systems 20
Correctness of Fragmentation
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 (Lossless Decomposition). Reconstruction If relation R is decomposed into fragments R1, R2, ..., Rn, then there should exist some relational operator such that R = 1inRi , Ri FR will be different for different forms of fragmentation. Ensures that constraints defined on the data in the form of dependencies are preserved. 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 ).
Dr. M. Alam Distributed Database Management Systems 21
Dr. M. Alam
22
Allocation Alternatives
Let database is fragmented properly, one has to allocate fragments to various sites over the network. Non-replicated Database
Partitioned : each fragment resides at only one site
Replicated Database
Fully replicated : each fragment at each site Partially replicated : each fragment at some of the sites
Replication is advantageous if
read - only queries update queries 1
Reference: W. W. Chu, Optimal File Allocation in Multiple Computer System, IEEE Transaction on Computers, 885-889, October 1969.
Dr. M. Alam Distributed Database Management Systems 23
Dr. M. Alam
Information Requirements
Database Information Application Information Communication Network Information Computer System Information
Dr. M. Alam
25
Database Information
Need to consult the conceptual DB design Apart from tables, we need relationships, cardinality and the owner and member tables Selectivity of fragments and size of a fragment How DB relations can be connected with each other (Join)? Directed links relate relations to each other using equi-join operation Owner(L1) = PAY while Member(L1) = EMP
PAY Title, Sal L1 EMP ID, Name, Title L2 ASIGN
Dr. M. Alam
PRJ
Application Information
Qualitative and Quantitative information Qualitative information : Guides fragmentation activity
User query uses Predicates, at least most important should be known. Simple Predicates : Given relation R[A1, A2, , An] pj : Ai Value A simple predicate pj is where {=,<,,>,,}, ValueDi & Di is the domain of Ai. For relation R we define Pr = {p1, p2, ,pm} Example : P-Name = Building, Bud 40M, .... Minterm Predicates M: Given R and Pr={p1, p2, ,pm} M={m1,m2,,mr} is defined as M={ mi|mi = p Pr pj* }, 1jm, 1iz j where pj* = pj or pj* = (pj). Some minterm predicates may be meaningless.
Dr. M. Alam Distributed Database Management Systems 27
Dr. M. Alam
28
Access Frequency
Frequency with which user application access data. acc(qi) gives frequency of query qi in given period. acc(mi)] represents frequency of minterm mi.
Dr. M. Alam
29
Dr. M. Alam
30
Dr. M. Alam
31
Horizontal Fragmentation
Partitions a relation along its tuples. Primary Horizontal Fragmentation (PHF)
Performed using predicates that are defined on that relation.
Dr. M. Alam
32
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.
Dr. M. Alam
33
PHF - Example
R1 = Sal 15K (R) R2 = Sal > 15K (R)
R
Id 1 2 3 Name Akram Bashir Saleem Sal 10K 15K 20K Dept. D1 D2 D3
R1
Id Name 1 Akram 2 Bashir Sal Dept. 10K D1 15K D2
R2
Id Name 3 Saleem Sal 20K Dept. D3
Dr. M. Alam
34
PHF Algorithm
Given: A relation R and the set of simple predicates Pr Output: The set of fragments of R = {R1, R2,,Rw} which obey the fragmentation rules. Preliminaries :
Pr should be complete Pr should be minimal
Dr. M. Alam
35
Example
Assume PRJ[P-ID, P-Name, Bud, LOC] has two applications defined on it. 1. Find the budgets of projects at each location. [Complete] 2. Find projects with budgets less than 40M. [Not Complete]
Dr. M. Alam Distributed Database Management Systems 36
Example of Minimality
PRJ1 : Projects with LOC=Karachi PRJ2 : Projects with LOC=Lahore, PRJ3 : Projects with Bud30M PRJ4 : Projects with Bud>30M Pr = {LOC=Karachi, LOC=Lahore, Bud30M, Bud>30M} is minimal (in addition to being complete). However, if we add P-Name = Building then Pr is no longer minimal because it is not relevant to Pr. No application would access resulting fragments differently.
Dr. M. Alam Distributed Database Management Systems 38
LOC Lahore
PRJ4 Bud 20M 30M LOC Karachi Karachi P-ID P2 P3 P-Name Flyover Building Bud 40M 50M LOC Lahore Islamabad
39
Dr. M. Alam
40
Dr. M. Alam
41
Apply COM-MIN Algorithm Initialize with i=1, results Pr = {p1} It is complete and minimal because p2 cant further partition f1 (Minterm fregments w.r..t p1) . So Pr =Pr= {p1,p2} Minterm predicates
m1 : (SAL 7000) m2 : (SAL 7000) = (SAL > 7000)
Dr. M. Alam Distributed Database Management Systems 43
Sal 5000 7000 6000 8500 9000 PAY2 Title Sal Engineer 8500 Analyst 9000
44
P-ID P1 P2 P3 P4
45
Empty Empty
Dr. M. Alam
PHF Example
PRJ1
P-ID P1 P4 P-Name Bridge School Bud LOC 20M Karachi 30M Karachi
PRJ2
P-ID P-Name Bud LOC
PRJ3
P-ID P-Name Bud LOC
PRJ4
P-ID P2 P-Name Flyover Bud 40M LOC Lahore
PRJ5
P-ID P-Name Bud LOC
PRJ6
P-ID P3 P-Name Building Bud 50M LOC Islamabad
48
Dr. M. Alam
PHF Correctness
Completeness
Resulting fragmentation is guaranteed to be complete as long as selection predicates are complete. Since Pr' is complete and minimal, the selection predicates are complete
Reconstruction
If relation R is fragmented into FR = {R1,R2,,Rr} R = R
i FR
Ri
Disjointness
Minterm predicates that form the basis of fragmentation should be mutually exclusive.
Dr. M. Alam Distributed Database Management Systems 49
Dr. M. Alam
50
DHF Example
Consider the link L1: Owner (L1) = PAY Member (L1) = EMP We want to group employees on the basis of their salaries one with salary less than or equal to 7000 and other more than that. Three inputs are needed: Partition of owner (PAY1 & PAY2), member relation, set of semijoin predicates between owner & member (EMP.Title = PAY.Title)
PAY Title, Sal L1 EMP ID, Name, Title L2 ASG
Dr. M. Alam
PRJ
Where
PAY1 = Sal 7000 (PAY) PAY2 = Sal > 7000 (PAY) A relation may have more than two Links!
More than one DHF are possible.
Dr. M. Alam Distributed Database Management Systems
53
DHF Correctness
Completeness
Difficult to define involvement of two relations. Let R be the member relation of a link whose owner is relation S which is fragmented as FS = {S1, S2, ..., Sn}. Furthermore, let A be the join attribute between R and S. Then, for each tuple t of R, there should be a tuple t' of S such that t[A]=t[A] Referential Integrity: Ensures that tuples of any fragment of the member are also in the owner relation. There is no ASG tuple which has a P-ID that is not also contained in PRJ. Similarly same Title appears in EMP & PAY.
Reconstruction
Same as primary horizontal fragmentation.
Disjointness
Simple join graphs between the owner and the member fragments.
Dr. M. Alam
55
Vertical Fragmentation
Dr. M. Alam
56
Vertical Fragmentation
More difficult than horizontal, because more alternatives exist. Easier to enforce functional dependencies. Approaches: Grouping & Splitting Grouping
Starts by assigning each attribute to one fragment At each step, joins some of the fragments until some criteria is satisfied. Results in overlapping fragments
Splitting
Starts with a relation and decides on beneficial partitioning based on the access behavior of applications to the attributes Fits more naturally within the top-down design Generates non-overlapping fragments.
Dr. M. Alam
57
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], use(qi, Aj) = 1 if attribute Aj is referenced by query qi 0 otherwise
VF Definition of use(qi,Aj)
Consider the following 4 queries for relation PRJ
q1: SELECT FROM WHERE SELECT FROM WHERE BUD PRJ P-ID=Value P-NAME PRJ LOC=Value A1 q1 q2 q3 q4
Dr. M. Alam
q2: SELECT P-NAME, BUD FROM PRJ q4: SELECT SUM(BUD) FROM PRJ WHERE LOC=Value A2 0 1 1 0 A3 1 1 0 1 A4 0 0 1 1
59
q3:
q1 q2 q3 q4 A1 A2 A3 A4
15
20
10
A1 A2 A3 A4 45 0 45 0 5 75 0 80 45 5 53 3 3 78 0 75
VF Clustering Algorithm
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. 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 AM is maximized. AM = (affinity of Ai and Aj with their neighbors) AM = aff(Ai,Aj) [aff(Ai,Aj-1)+aff( Ai,Aj+1)+aff(Ai-1,Aj)+aff(Ai+1, Aj)]
i j n n i j n n
Where
n n i j
where
Dr. M. Alam
64
BEA Example
Consider the following AA matrix and the corresponding CA matrix where A1 and A2 have been placed. Place A3:
A1 A2 AA = A3 A4 A1 45 0 45 0 A2 A3 0 5 80 5 5 53 75 3 A4 0 75 3 78 A1 45 0 CA = 45 0 A2 0 80 5 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 = 2bond(A1 , A3)+2bond(A3 , A2)2bond(A1,A2) = 2* 4410 + 2* 890 2*225 = 10150
Ordering (1-3-2) :
cont(A1,A3,A2)
= 1780
66
BEA Example
A1 A3 A2 45 45 0 80 5
45 53 0
3 75
A 1 A 3 A2 A4
When A4 is placed, the final form of the CA matrix (after row organization) is Top-left Low affinity measure High affinity measure
Distributed Database Management Systems
A 1 45 A 3 45 A2 A4 0 0
45 53
0 5
0 3 75 78
5 80 3 75
Bottom-Right
Dr. M. Alam
67
VF Algorithm
Divide a set of clustered attributes A={A1, A2, , An} into two (or more) sets {A1, A2, , Ai} and {Ai, Ai+1, , An} such that there are no (or minimal) applications that access both (or more than one) of the sets. Set of Applications = Q = {q1, q2, , qq}
A1 A2 A3 Ai Ai+1 . . .Am A1 A2 Ai Ai+1 Am
Dr. M. Alam Distributed Database Management Systems 68
... ...
TA
BA
VF Algorithm (Definitions)
AQ = = TQ = = BQ = = OQ = = Set of applications that access A { Aj \ use(qi, Aj) = 1 } Set of applications that access only TA { qj \ AQ(qi) belongs to TA } Set of applications that access only BA { qj \ AQ(qi) belongs to BA } Set of applications that access both TA and BA Q - { TQ BQ }
Dr. M. Alam
69
VF Algorithm (Definitions)
CTQ = Total no. of accesses to attributes of only TA by applications CTQ =
qi BQ TQ
Refj(qi) accj(qi)
Refj(qi) accj(qi)
VF Algorithm (Problems)
1.
2.
Dr. M. Alam
71
VF Example
Apply partition algorithm to the CA matrix obtained for relation PRJ.
A 1 A 3 A2 A4 A 1 45 A 3 45 A2 A4 0 0 45 53 0 5 0 3 75 78
5 80 3 75
Result: FPRJ = { PRJ1, PRJ2} PRJ1 = { A1, A3 } = {P-ID, Bud} PRJ2 = { A1, A2, A4 } = {P-ID, P-Name, LOC} **Each Ri contains key attribute(s) or system assigned tuple IDs (TIDs)
Dr. M. Alam Distributed Database Management Systems 72
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 = AR
i
Reconstruction
Reconstruction can be achieved by R= Ri FR K Ri
Disjointness
TID's are not considered to be overlapping since these are maintained by the system totally invisible to the users. Duplicated keys are not considered to be overlapping
Dr. M. Alam Distributed Database Management Systems 73
Hybrid Fragmentation
Horizontal or vertical fragmentation is not sufficient to satisfy the requirements of user applications. Consists of a horizontal fragment that is vertically fragmented, or a vertical fragment that is horizontally fragmented. In horizontal fragmentation, minimum size of a fragment is one tuple, whereas in vertical fragmentation is one attribute per fragment. p(a1, ... ,an(R)) or a1, ... ,an(p(R))
R HF R1 VF R11
Dr. M. Alam
HF R2
VF R12
VF R21
VF R22
VF R23
74
R HF R2 VF R22 HF R3
R11 R12
Dr. M. Alam
75
Disjointness
If intermediate & leaf fragments are disjoint then hybrid fragmentation is also disjoint.
Reconstruction
Start from leaves of partitioning tree & moves upward performing joins & unions. (See Figure)
R11
Dr. M. Alam
R12
R21
R22
R23
76
Allocation Model
Dr. M. Alam
77
Fragment Allocation
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.
Optimality
Minimal cost: (Usually in terms of time) Communication + storage + processing (querying & update) Performance: Response time and/or throughput Constraints: Per site constraints (storage & processing)
Dr. M. Alam
78
Information Requirements
Database information
selectivity of fragments size of a fragment
Application information
access types and numbers access localities
Allocation
File Allocation (FAP) vs Database Allocation (DAP)
FAP model separates query processing cost into two parts: retrieval processing cost & update processing cost. In DAP model query processing cost is consist of processing cost (PC)& Transmission cost (TC).
Cost of integrity enforcement (IE) should be considered Cost of concurrency control (CC) should be considered
Dr. M. Alam Distributed Database Management Systems 80
Site Information
Network Information
Allocation Model
Object: Minimize the total cost of processing & storage while meeting the certain constraints General Form min(Total Cost) subject to Response time constraint Storage constraint Processing constraint Decision Variable
xij =
Dr. M. Alam
1 0
all queries Query processing cost (QPCi) + all sites all fragments Fragment storing cost at a site (STCjk)
Storage Cost (of fragment Fj at site Sk)
USCk * size( Fj) * xjk
[ STCjk ] [QPCi ]
Dr. M. Alam
83
Allocation Model
Query Processing Cost
Processing component
Access cost + Integrity enforcement cost + Concurrency control cost
Access cost
ACi= all sites all fragments (ujk * URij + rij * RRjk ) * xjk * LPCk Integrity enforcement and concurrency control costs can be similarly calculated. For this unit local processing cost will be different. (Discussed in Chapter 6 & 11 in detail)
Dr. M. Alam Distributed Database Management Systems 84
Allocation Model
Query Processing Cost
Transmission Component Cost of processing updates + Cost of processing retrievals Cost of Updates (Inform all replicas)
all sites all fragments Update message cost + all sites all fragments Acknowledgment cost
Cost of retrievals
Storage Constraint
Processing Constraint
all queries
Dr. M. Alam
86
Allocation Model
Solution Methods
FAP is NP-complete DAP is also NP-complete
Heuristics based on
Single commodity warehouse location (for FAP) Knapsack problem Branch and bound techniques Network flow algorithm
Dr. M. Alam Distributed Database Management Systems 87
NP-Complete
1.
2.
NP refers to "nondeterministic polynomial time." NP is the set of all decision problems for which the instances where the answer is "yes" have efficiently verifiable proofs of the fact that the answer is indeed "yes." More precisely, these proofs have to be verifiable in polynomial time by a deterministic Turing machine. OR NP is the set of decision problems where the "yes"-instances can be recognized in polynomial time by a non-deterministic Turing machine. The equivalence of the two definitions follows from the fact that an algorithm on such a non-deterministic machine consists of two phases, the first of which consists of a guess about the solution which is generated in a non-deterministic way, while the second consists of a deterministic algorithm which verifies or rejects the guess as a valid solution to the problem.
Distributed Database Management Systems 88
Dr. M. Alam
Dr. M. Alam
89