+ All Categories
Home > Documents > Distributed Database Design

Distributed Database Design

Date post: 16-Jan-2016
Category:
Upload: sheenambhatia
View: 24 times
Download: 2 times
Share this document with a friend
Description:
Designing of a Distributed Database

of 73

Click here to load reader

Transcript

Outline

Distributed Database DesignTOPICSDistributed database design concept, objective of Data Distribution, Data Fragmentation, The allocation of fragment , Transparencies in Distributed Database DesignDesign ProblemIn 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.In Distributed DBMS, the placement of applications entailsplacement of the distributed DBMS software; andplacement of the applications that run on the databaseDimensions of the ProblemLevel of sharingLevel of knowledgeAccess pattern behaviorpartialinformation dynamicstaticdatadata +programcompleteinformationDistribution DesignTop-downmostly in designing systems from scratchmostly in homogeneous systemsBottom-upwhen the databases already exist at a number of sitesTop-Down DesignUser InputView IntegrationUser InputRequirementsAnalysisObjectivesConceptualDesignView DesignAccessInformationESsGCSDistributionDesignPhysicalDesignLCSsLISsDistribution Design IssuesWhy fragment at all?How to fragment?How much to fragment?How to test correctness?How to allocate?Information requirements?FragmentationCan't we just distribute relations?What is a reasonable unit of distribution?relationviews are subsets of relations locality extra communicationfragments of relations (sub-relations)concurrent execution of a number of transactions that access different portions of a relationviews that cannot be defined on a single fragment will require extra processingsemantic data control (especially integrity enforcement) more difficultFragmentation Alternatives HorizontalPROJ1 :projects with budgets less than $200,000PROJ2 :projects with budgets greater than or equal to $200,000PROJ1PNOPNAMEBUDGETLOCP3 CAD/CAM250000New YorkP4Maintenance310000ParisP5CAD/CAM500000BostonPNOPNAMELOCP1Instrumentation150000MontrealP2Database Develop.135000New YorkBUDGETPROJ2New YorkNew YorkPROJPNOPNAMEBUDGETLOCP1Instrumentation150000MontrealP3 CAD/CAM250000P2Database Develop.135000P4Maintenance310000ParisP5CAD/CAM500000BostonFragmentation Alternatives VerticalPROJ1:information about project budgetsPROJ2:information about project names and locationsPNOBUDGETP1150000P3 250000P2135000P4310000P5500000PNOPNAMELOCP1InstrumentationMontrealP3 CAD/CAMNew YorkP2Database Develop.New YorkP4MaintenanceParisP5CAD/CAMBostonPROJ1PROJ2New YorkNew YorkPROJPNOPNAMEBUDGETLOCP1Instrumentation150000MontrealP3 CAD/CAM250000P2Database Develop.135000P4Maintenance310000ParisP5CAD/CAM500000BostonDegree of FragmentationFinding the suitable level of partitioning within this range

tuplesorattributesrelationsfinite number of alternativesCorrectness of FragmentationCompletenessDecomposition 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 RiReconstructionIf relation R is decomposed into fragments R1, R2, ..., Rn, then there should exist some relational operator such thatR = 1inRiDisjointness 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 AlternativesNon-replicatedpartitioned : each fragment resides at only one siteReplicatedfully replicated : each fragment at each sitepartially replicated : each fragment at some of the sites

Rule of thumb:

Full-replicationPartial-replicationPartitioningQUERY PROCESSINGEasySame DifficultySame DifficultyDIRECTORYMANAGEMENT Easy orNon-existantCONCURRENCYCONTROLEasyDifficultModerateRELIABILITYVery highHighLowREALITYPossibleapplicationRealisticPossibleapplicationComparison of Replication AlternativesInformation RequirementsFour categories:Database informationApplication informationCommunication network informationComputer system informationPHF Information RequirementsDatabase Informationrelationship

cardinality of each relation: card(R)TITLE, SALSKILLENO, ENAME, TITLEPNO, PNAME, BUDGET, LOCENO, PNO, RESP, DUREMPPROJASGL1

Application Information Qualitative InformationThe fundamental qualitative information consists of the predicates used in user queries. Analyze user queries based on 80/20 rule: 20% of user queries account for 80% of the total data access.One should investigate the more important queriesQuantitative Information Minterm Selectivity sel(mi): number of tuples that would be accessed by a query specified according to a given minterm predicate. Access Frequency acc(mi): the access frequency of a given minterm predicate in a given period.

FragmentationHorizontal Fragmentation (HF)Primary Horizontal Fragmentation (PHF)Derived Horizontal Fragmentation (DHF)Vertical Fragmentation (VF)Hybrid Fragmentation (HF)

Primary Horizontal FragmentationEMP tableThree branch offices, with each employee working at only one office Create table MPLS_EMPS asSelect * From EMP Where Loc = Minneapolis;

Create table LA_EMPS asSelect *From EMP Where Loc = LA;

Create table NY_EMPS as Select *From EMP Where Loc = New York;After fragmentationSelect * from MPLS_EMPSUnionSelect * from LA_EMPS)UnionSelect * from NY_EMPS;

Example 1AP1:looking for those employees who work in Los Angeles (LA).Pr = {p1: Loc= LA}M= {m1: Loc = LA, m2: LocLA}is a minimal and complete set of minterm predicates for AP1Fragment F1: Create table LA_EMPS as Select * from EMP Where Loc = "LA";Fragment F2: Create table NON_LA_EMPS as Select * from EMP Where Loc "LA";Minimal :the rows are accessed differently by at least one application.Complete :the rows have the same probability of being accessed by any application.AP1:Exclude any employee whose salary was less than or equal to 30000Pr = {p1: Loc = "LA,p2: salary > 30000}M = {m1: Loc = "LA" Sal > 30000, m2: Loc = "LA" Sal 30000, m4: Loc "LA" Sal 200000} which is complete.

Find projects with budgets less than $200000.(2)

Minimality of Simple PredicatesIf a predicate influences how fragmentation is performed, (i.e., causes a fragment f to be further fragmented into, say, fi and fj) then there should be at least one application that accesses fi and fj differently. In other words, the simple predicate should be relevant in determining a fragmentation. If all the predicates of a set Pr are relevant, then Pr is minimal.

Minimality of Simple PredicatesExample :Pr ={LOC=Montreal,LOC=New York, LOC=Paris, BUDGET200000,BUDGET>200000}is minimal (in addition to being complete). However, if we addPNAME = Instrumentationthen Pr is not minimal.COM_MIN AlgorithmGiven:a relation R and a set of simple predicates Pr Output:a complete and minimal set of simple predicates Pr' for PrRule 1:a relation or fragment is partitioned into at least two parts which are accessed differently by at least one application.COM_MIN AlgorithmInitialization :find a pi Pr such that pi partitions R according to Rule 1set Pr' = pi ; Pr Pr {pi} ; F {fi}Iteratively add predicates to Pr' until it is completefind a pj Pr such that pj partitions some fk defined according to minterm predicate over Pr' according to Rule 1set Pr' = Pr' {pj }; Pr Pr {pj }; F F {fi} if pk Pr' which is nonrelevant thenPr' Pr {pk}F F {fk}PHORIZONTAL AlgorithmMakes use of COM_MIN to perform fragmentation.Input:a relation R and a set of simple predicates PrOutput:a set of minterm predicates M according to which relation R is to be fragmented

Pr' COM_MIN (R,Pr)determine the set M of minterm predicatesdetermine the set I of implications among pi Preliminate the contradictory minterms from M PHF Example 3Two candidate relations : PAY and PROJ.Fragmentation of relation PAY Application: Check the salary info and determine raise.Employee records kept at two sites application run at two sitesSimple predicatesp1 : SAL 30000p2 : SAL > 30000Pr = {p1,p2} which is complete and minimal Pr'=PrMinterm predicatesm1 : (SAL 30000)m2 : NOT(SAL 30000) = (SAL > 30000)PHF Example 3TITLEMech. Eng.ProgrammerSAL2700024000PAY1PAY2TITLEElect. Eng.Syst. Anal.SAL4000034000

PHF Example 3Fragmentation of relation PROJ Applications:Find the name and budget of projects given their no.Issued at three sitesAccess project information according to budget one site accesses 200000 other accesses >200000Simple predicatesFor application (1) p1 : LOC = Montrealp2 : LOC = New Yorkp3 : LOC = ParisFor application (2)p4 : BUDGET 200000p5 : BUDGET > 200000Pr = Pr' = {p1,p2,p3,p4,p5}

PHF Example 3Fragmentation of relation PROJ continuedMinterm fragments left m1 : (LOC = Montreal) (BUDGET 200000)m2 : (LOC = Montreal) (BUDGET > 200000)m3 : (LOC = New York) (BUDGET 200000)m4 : (LOC = New York) (BUDGET > 200000)m5 : (LOC = Paris) (BUDGET 200000)m6 : (LOC = Paris) (BUDGET > 200000)PHF ExamplePROJ1PNOPNAMEBUDGETLOCPNOPNAMEBUDGETLOCP1Instrumentation150000MontrealP2DatabaseDevelop.135000New YorkPROJ2PROJ4PROJ6PNOPNAMEBUDGETLOCP3 CAD/CAM250000New YorkPNOPNAMEBUDGETLOCMaintenanceP4310000ParisPHF CorrectnessCompletenessSince Pr' is complete and minimal, the selection predicates are completeReconstructionIf relation R is fragmented into FR = {R1,R2,,Rr}R = Ri FR Ri DisjointnessMinterm predicates that form the basis of fragmentation should be mutually exclusive. Derived Horizontal FragmentationDefined on a member relation of a link according to a selection operation specified on its owner.Each link is an equijoin.Equijoin can be implemented by means of semijoins.TITLE,SALSKILLENO, ENAME, TITLEPNO, PNAME, BUDGET, LOCENO, PNO,RESP, DUREMPPROJASGL1L2L3DHF DefinitionGiven a link L where owner(L)=S and member(L)=R, the derived horizontal fragments of R are defined asRi = R F Si, 1iwwhere w is the maximum number of fragments that will be defined on R andSi = Fi (S)where Fi is the formula according to which the primary horizontal fragment Si is defined.DHF ExampleGiven link L1 where owner(L1)=SKILL/PAY and member(L1)=EMPGroup engineers into two groups according to their salary: those making less than or equal to $30,000, and those making more than $30,000.

EMP1 = EMP SKILL/PAY1EMP2 = EMP SKILL/PAY2whereSKILL/PAY1 = SAL30000(SKILL/PAY)SKILL/PAY2 = SAL>30000(SKILL/PAY)ENOENAMETITLEE3A. LeeMech. Eng.E4J. MillerProgrammerE7R. DavisMech. Eng.EMP1ENOENAMETITLEE1J. DoeElect. Eng.E2M. SmithSyst. Anal.E5B. CaseySyst. Anal.EMP2E6L. ChuElect. Eng.E8J. JonesSyst. Anal.

DHF CorrectnessCompletenessReferential integrityLet 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 thatt[A] = t' [A]ReconstructionSame as primary horizontal fragmentation.DisjointnessSimple join graphs between the owner and the member fragments.

Vertical FragmentationGroup the columns of a table into fragments.Because each fragment contains a subset of the total set of columns in the table, VF can be used to enforce security and/or privacy of data.More difficult than horizontal, because more alternatives exist. In the case of vertical partitioning, if a relation has m non-primary key attributes, the number of possible fragments is equal to B(m), which is the mth Bell number

Two approaches :groupingattributes to fragmentsfirst step creates as many vertical fragments as the number of non-key columns in the table. Then grouping approach uses joins across the primary key, to group some of these fragments together, and continues as neededNot usually considered a valid approachsplittingrelation to fragmentsplacing each non-key column in one and only one fragmentNeed to design affinity or closenessIf a table has 15 columns, then the number of possible vertical fragments is 109 and If the number of vertical fragments for a table with 30 columns is 1023. Evaluating is not practical.Sol : Find the closeness/affinity between the attributes to decide whether to group them into same fragment or notVF Information RequirementsApplication InformationAttribute affinitiesa measure that indicates how closely related the attributes areThis is obtained by: access frequency + usage patternAccess freq: how many times an application/query runs in a given period of time at different sitesUsage pattern:Indicates whether a column is used by an application/query.Attribute usage valuesGiven a set of queries Q = {q1, q2,, qq} that will run on the relation R[A1, A2,, An],

use(qi,) can be defined accordinglyuse(qi,Aj) =1 if attribute Aj is referenced by query qi0 otherwiseVF Definition of use(qi,Aj)Consider the following 4 queries for relation PROJq1:SELECTBUDGETq2:SELECTPNAME,BUDGETFROMPROJFROMPROJWHEREPNO=Valueq3:SELECTPNAMEq4:SELECTSUM(BUDGET)FROMPROJFROMPROJWHERELOC=ValueWHERELOC=ValueLet A1= PNO, A2= PNAME, A3= BUDGET, A4= LOCq1q2q3q4A11010001100110011A2A3A4

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 :

aff (Ai, Aj) (query access)all queries that access Ai and Aj query access access frequency of a query accessexecutionall sitesVF Calculation of aff(Ai, Aj)Example: Assume each query in the previous example accesses the attributes once during each execution. Also assume the access frequencies

Then aff(A1, A3)= 15*1 + 20*1+10*1= 45and the attribute affinity matrix AA is4q1q2q3qS1S2S3152010500252525300AAAA1234AAAA12344504500805754555330753781010001100110011q1q2q3q450VF Clustering AlgorithmTake 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 is maximized. Bond Energy AlgorithmInput:The AA affinity matrixOutput:The clustered affinity matrix CA which is a perturbationof 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 AlgorithmBest placement? Define contribution of a placement:

cont(Ai, Ak, Aj) = 2bond(Ai, Ak)+2bond(Ak, Al) 2bond(Ai, Aj)

where

bond(Ax,Ay) =aff(Az,Ax)aff(Az,Ay)z 1n BEA ExampleConsider the following AA matrix and the corresponding CA matrix where A1 and A2 have been placed. Place A3:

Ordering (0-3-1) :cont(A0,A3,A1)= 2bond(A0 , A3)+2bond(A3 , A1)2bond(A0 , A1)= 2* 0 + 2* 4410 2*0 = 8820Ordering (1-3-2) :cont(A1,A3,A2)= 2bond(A1 , A3)+2bond(A3 , A2)2bond(A1,A2)= 2* 4410 + 2* 890 2*225 = 10150Ordering (2-3-4) :cont (A2,A3,A4)= 1780

BEA ExampleTherefore, the CA matrix has the form

When A4 is placed, the final form of the CA matrix (after row organization) is

A1A2A345 045 045 5

53 3 080 575A1A2A3A4A1A2A3A44545 0 04553

5 3 0 58075 0 37578VF AlgorithmHow 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.the function will produce fragments that are balanced.For Best partitioning split the columns into a one-column BC and n 1 column TC first , and then repeatedly add columns from TC to BC until TC isleft with only one column.choose the splitting that has the highest Z value.Z can be positive if total accesses to only one fragment are maximized while the total accesses to both fragments are minimizedDisadvantage :Not able to carve out an embedded or inner block of columns as a partition.Sol: Overcome by adding a shift operation(moves the topmost row of the matrix to the bottom and then it moves the leftmost column of the matrix to the extreme right)A1A2AiAi+1AmA1A2A3AiAi+1AmBA. . . . . . . . . TASHIFT OPERATION

VF ALgorithmDefineTQ=set of applications that access only TA(Top corner attributes)BQ=set of applications that access only BAOQ=set of applications that access both TA and BAandCTQ =total number of accesses to attributes by applications that access only TACBQ =total number of accesses to attributes by applications that access only BACOQ =total number of accesses to attributes by applications that access both TA and BAThen find the point along the diagonal that maximizes Goal Function: Z =CTQCBQCOQ2 Example1) TC: all the applications that access one of the TC columns (C4, C1, or C3) but do not access any BC [i.e AP1, AP2, and AP4]No application is BC-only.AP3 accesses both TC and BC columns,

TCW = AFF(AP1) + AFF(AP2) + AFF(AP4) = 3 + 7 + 3 = 13BCW = none = 0BOCW = AFF(AP3) = 4Z = 13*0 42 = 162) TC TCW = AFF(AP1) + AFF(AP2) = 3 + 7 = 10BCW = AFF(AP3) = 4BOCW = AFF(AP4) = 3Z = 4*10 32 = 40 9 = 31

Result :The two vertical fragments will be defined as VF1(C, C4) and VF2(C, C1, C2, C3).

3)TCW = AFF(AP2) = 7BCW = AFF(AP3) + AFF(AP4) = 4 + 3 = 7BOCW = AFF(AP1) = 3Z = 7*7 32 = 49 9 = 40

4)TCW = AFF(AP4) = 3BCW = AFF(AP2) = 7BOCW = AFF(AP1) + AFF(AP3) = 3 + 4 = 7Z = 3*7 72 = 21 49 = 28

VF AlgorithmTwo problems :Cluster forming in the middle of the CA matrixShift a row up and a column left and apply the algorithm to find the best partitioning pointDo this for all possible shiftsCost O(m2)More than two clustersm-way partitioningtry 1, 2, , m1 split points along diagonal and try to find the best point for each of these Cost O(2m)VF CorrectnessA relation R, defined over attribute set A and key K, generates the vertical partitioning FR = {R1, R2, , Rr}.CompletenessThe following should be true for A:A = ARiReconstructionReconstruction can be achieved byR = K Ri, Ri FRDisjointnessTID's are not considered to be overlapping since they are maintained by the systemDuplicated keys are not considered to be overlappingHybrid FragmentationRHFHFR1VFVFVFVFVFR11R12R21R22R23R2Fragment AllocationProblem StatementGiven F = {F1, F2, , Fn} fragmentsS ={S1, S2, , Sm} network sites Q = {q1, q2,, qq}applications Find the "optimal" distribution of F to S.OptimalityMinimal costCommunication + storage + processing (read & update)Cost in terms of time (usually)PerformanceResponse time and/or throughputConstraintsPer site constraints (storage & processing)Information RequirementsDatabase informationselectivity of fragments size of a fragment Application informationaccess types and numbers access localities Communication network information unit cost of storing data at a site unit cost of processing at a site Computer system information bandwidth latency communication overhead AllocationFile Allocation (FAP) vs Database Allocation (DAP):Fragments are not individual filesrelationships have to be maintainedAccess to databases is more complicatedremote file access model not applicablerelationship between allocation and query processingCost of integrity enforcement should be consideredCost of concurrency control should be consideredAllocation Information RequirementsDatabase Informationselectivity of fragments size of a fragment Application Informationnumber of read accesses of a query to a fragmentnumber of update accesses of query to a fragmentA matrix indicating which queries updates which fragmentsA similar matrix for retrievalsoriginating site of each query Site Informationunit cost of storing data at a site unit cost of processing at a siteNetwork Informationcommunication cost/frame between two sitesframe sizeAllocation ModelGeneral Formmin(Total Cost)subject toresponse time constraintstorage constraintprocessing constraint

Decision Variablexij 1 if fragment Fi is stored at site Sj 0 otherwiseAllocation ModelTotal Cost

Storage Cost (of fragment Fj at Sk)Query Processing Cost (for one query)processing component + transmission component (unit storage cost at Sk) (size of Fj) xjk query processing cost all queries cost of storing a fragment at a siteall fragmentsall sites Allocation ModelQuery Processing CostProcessing componentaccess cost + integrity enforcement cost + concurrency control costAccess cost

Integrity enforcement and concurrency control costsCan be similarly calculated (no. of update accesses+ no. of read accesses) all fragmentsall sitesxij local processing cost at a siteAllocation ModelQuery Processing CostTransmission componentcost of processing updates + cost of processing retrievalsCost of updates

Retrieval Cost

update message cost all fragmentsall sites acknowledgment cost all fragmentsall sites minall sitesall fragments(cost of retrieval command cost of sending back the result)Allocation ModelConstraintsResponse Timeexecution time of query max. allowable response time for that query Storage Constraint (for a site)

Processing constraint (for a site)

storage requirement of a fragment at that site all fragmentsstorage capacity at that site processing load of a query at that site all queriesprocessing capacity of that siteAllocation ModelSolution MethodsFAP is NP-completeDAP also NP-completeHeuristics based onsingle commodity warehouse location (for FAP)knapsack problembranch and bound techniquesnetwork flowAllocation ModelAttempts to reduce the solution spaceassume all candidate partitionings known; select the best partitioningignore replication at firstsliding window on fragments


Recommended