39
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University

PMIT-6102 Advanced Database Systems

  • Upload
    myrna

  • View
    70

  • Download
    0

Embed Size (px)

DESCRIPTION

PMIT-6102 Advanced Database Systems. By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University. Lecture 05 Distributed Database Design . Outline. Distributed Database Design Distributed Design Issues Fragmentation Data Allocation. Degree of Fragmentation. - PowerPoint PPT Presentation

Citation preview

Page 1: PMIT-6102 Advanced Database Systems

PMIT-6102Advanced Database Systems

By-Jesmin Akhter

Assistant Professor, IIT, Jahangirnagar University

Page 2: PMIT-6102 Advanced Database Systems

Lecture 05 Distributed Database Design

Page 3: PMIT-6102 Advanced Database Systems

Outline Distributed Database Design

Distributed Design Issueso Fragmentationo Data Allocation

Slide 3

Page 4: PMIT-6102 Advanced Database Systems

Degree of Fragmentation

Finding the suitable level of partitioning within this range

To fragment to the level of individuals tuplesor

To fragment to the level of individuals attributes

Relations(Not to fragment at all)

finite number of alternatives

Page 5: PMIT-6102 Advanced Database Systems

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

This property, which is identical to the lossless decomposition property of normalization

it ensures that the data in a global relation are mapped into fragments without any loss

Slide 5

Page 6: PMIT-6102 Advanced Database Systems

Correctness of Fragmentation

Reconstruction If relation R is decomposed into fragments FR={R1,

R2, ..., Rn}, then there should exist some relational operator ∇ such that

R = Ri ,∇ The reconstructability of the relation from its fragments

ensures that constraints defined on the data in the form of dependencies are preserved.

Slide 6

Page 7: PMIT-6102 Advanced Database Systems

Correctness of Fragmentation

Disjointness If relation R is horizontally decomposed into fragments

FR={R1, R2, ..., Rn}, and data item dj is in Rj, then dj should not be in any other fragment Rk (k ≠ j ).

This criterion ensures that the horizontal fragments are disjoint.

If relation R is vertically decomposed, its primary key attributes are typically repeated in all its fragments (for reconstruction).

Therefore, in case of vertical partitioning, disjointness is defined only on the non-primary key attributes of a relation.

Slide 7

Page 8: PMIT-6102 Advanced Database Systems

Allocation Alternatives

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

Slide 8

Page 9: PMIT-6102 Advanced Database Systems

Comparison of Replication Alternatives

Slide 9

Page 10: PMIT-6102 Advanced Database Systems

Information Requirements

The information needed for distribution design can be divided into four categories: Database information Application information Communication network information Computer system information

Slide 10

Page 11: PMIT-6102 Advanced Database Systems

Fragmentation

Horizontal Fragmentation (HF) Vertical Fragmentation (VF) Hybrid Fragmentation (HF)

Slide 11

Page 12: PMIT-6102 Advanced Database Systems

Horizontal Fragmentation (HF)

Horizontal fragmentation partitions a relation along its tuples. each fragment has a subset of the tuples of the relation.

There are two versions of horizontal partitioning: Primary horizontal fragmentation Derived horizontal fragmentation

Primary horizontal fragmentation of a relation is performed using predicates that are defined on that relation.

Derived horizontal fragmentation is the partitioning of a relation results from predicates being defined on another relation.

Slide 12

Page 13: PMIT-6102 Advanced Database Systems

Information Requirements of HF

Database Information how the database relations are connected to one another,

especially with joins. In the relational model, these relationships are also depicted

as relations.

cardinality of each relation: card(R)

TITLE, SALSKILL

ENO, ENAME, TITLE PNO, PNAME, BUDGET, LOC

ENO, PNO, RESP, DUR

EMP PROJ

ASG

L1

L2 L3

Expression of Relationships Among Relations Using Links

Slide 13

Page 14: PMIT-6102 Advanced Database Systems

Information Requirements of HF

14

The direction of the link shows a one to many relationship. For each title there are multiple employees with their title. Thus there is a link between PAY and EMP relations.

Page 15: PMIT-6102 Advanced Database Systems

Application Information simple predicates : Given R[A1, A2, …, An], a simple

predicate pj ispj : 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

Information Requirements of HF

Slide 15

Page 16: PMIT-6102 Advanced Database Systems

Application Information minterm predicates : Given R and Pr = {p1, p2, …,pm}

define M = {m1,m2,…,mr} as

M = { mi | mi = pjPr pj* }, 1≤j≤m, 1≤i≤z

where pj* = pj or pj* = ¬(pj).

Information Requirements of HF

Example

m1: PNAME="Maintenance" BUDGET≤200000

m2: NOT(PNAME="Maintenance") BUDGET≤200000

m3: PNAME= "Maintenance" NOT(BUDGET≤200000)

m4: NOT(PNAME="Maintenance") NOT(BUDGET≤200000)

Slide 16

Page 17: PMIT-6102 Advanced Database Systems

Application Information In terms of quantitative information about user applications,

we need to have two sets of data. minterm selectivities: sel(mi)

o 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.

access frequencies: acc(qi)o The frequency with which a user application qi accesses

data.o Access frequency for a minterm predicate can also be

defined.

Information Requirements of HF

Slide 17

Page 18: PMIT-6102 Advanced Database Systems

Primary Horizontal Fragmentation Definition :

A primary horizontal fragmentation is defined by a selection operation on the owner relations of a database schema. Therefore, given relation R, its horizontal fragments are given by

Ri = Fi(R), 1 ≤ i ≤ w

where Fi is a selection formula used to obtain fragment Ri. If Fi is in conjunctive normal form, it is a minterm predicate (mi). 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.

Slide 18

Page 19: PMIT-6102 Advanced Database Systems

Primary Horizontal Fragmentation PROJ1 = LOC=“Montreal” (PROJ) PROJ2 = LOC=“New York” (PROJ) PROJ3 = LOC=“Paris” (PROJ)

Slide 19Primary Horizontal Fragmentation of Relation PROJ

Page 20: PMIT-6102 Advanced Database Systems

PHF – AlgorithmGiven: A relation R, the set of simple predicates PrOutput: The set of fragments of R = {R1, R2,…,Rw} which

obey the fragmentation rules.

Preliminaries :Pr should be completePr should be minimal

Slide 20

Page 21: PMIT-6102 Advanced Database Systems

Completeness of Simple Predicates A set of simple predicates Pr is said to be complete if

and only if there is an equal probability of access by every application to any tuple belonging to any minterm fragment that is defined according to 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)

Slide 21

Page 22: PMIT-6102 Advanced Database Systems

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.

Slide 22

Page 23: PMIT-6102 Advanced Database Systems

Minimality of Simple Predicates If 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.

Pi is relevant if and only if

acc(mi ) the access frequency of a minterm mi.

Slide 23

)()(

)()(

j

j

i

i

fcardmacc

fcardmacc

Page 24: PMIT-6102 Advanced Database Systems

Minimality of Simple Predicates

Example :

Pr ={LOC=“Montreal”,LOC=“New York”, LOC=“Paris”, BUDGET≤200000,BUDGET>200000}

is minimal (in addition to being complete). However, if we add

PNAME = “Instrumentation”

then Pr is not minimal.

Slide 24

Page 25: PMIT-6102 Advanced Database Systems

COM_MIN AlgorithmGiven: a relation R and a set of simple predicates Pr Output: a complete and minimal set of simple predicates

Pr' for Pr

Rule 1: a relation or fragment is partitioned into at least two parts which are accessed differently by at least one application.

Slide 25

Page 26: PMIT-6102 Advanced Database Systems

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}

Iteratively add predicates to Pr' until it is complete find a pj Pr such that pj partitions some fk defined

according to minterm predicate over Pr' according to Rule 1 set Pr' = Pr' {pj}; Pr Pr – {pj}; F F {fj} if pk Pr' which is nonrelevant then

Pr' Pr' – {pk}

F F – {fk}

Slide 26

Page 27: PMIT-6102 Advanced Database Systems

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 predicates determine the set I of implications among pi Pr‘ Iteratively eliminate the contradictory minterms from M M M-mi

Slide 27

Page 28: PMIT-6102 Advanced Database Systems

PHF – Example Two 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 sites Simple predicates

p1 : SAL ≤ 30000

p2 : SAL > 30000

Pr = {p1,p2} which is complete and minimal Pr'=Pr Minterm predicates

m1 : (SAL ≤ 30000)

m2 : NOT(SAL ≤ 30000) (SAL > 30000)

Slide 28

Page 29: PMIT-6102 Advanced Database Systems

PHF – Example

TITLEMech. Eng.Programmer

SAL

2700024000

PAY1 PAY2

TITLEElect. Eng.Syst. Anal.

SAL

4000034000

Slide 29

Page 30: PMIT-6102 Advanced Database Systems

PHF – Example Fragmentation of relation PROJ

Applications:o Find the name and budget of projects given their location.

– Issued at three siteso 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 ≤ 200000p5 : BUDGET > 200000

Pr = Pr' = {p1,p2,p3,p4,p5}Slide 30

Page 31: PMIT-6102 Advanced Database Systems

Fragmentation of relation PROJ continued Minterm fragments left after elimination

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 – Example

Slide 31

Page 32: PMIT-6102 Advanced Database Systems

PHF – Example

PROJ1

PNO PNAME BUDGET LOC PNO PNAME BUDGET LOC

P1 Instrumentation 150000 Montreal

P2 Database Develop.135000 New York

PROJ3

PROJ4 PROJ6

PNO PNAME BUDGET LOC

P3 CAD/CAM 250000 New York

PNO PNAME BUDGET LOC

MaintenanceP4 310000 Paris

The result of the primary horizontal fragmentation of PROJ forms six fragments FPROJ = {PROJ1, PROJ2, PROJ3, PROJ4, PROJ5, PROJ} according to the minterm predicates M . Since fragments PROJ2, and PROJ5 are empty, they are not depicted in Figure

Slide 32

Page 33: PMIT-6102 Advanced Database Systems

Completeness Since Pr' is complete and minimal, the selection predicates are complete

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.

PHF – Correctness

Slide 33

Page 34: PMIT-6102 Advanced Database Systems

Solved Problem

Slide 34

Page 35: PMIT-6102 Advanced Database Systems

Solved Problem

Slide 35

Page 36: PMIT-6102 Advanced Database Systems

Solved Problem

Slide 36

Page 37: PMIT-6102 Advanced Database Systems

Solved Problem

Slide 37

Page 38: PMIT-6102 Advanced Database Systems

Solved Problem

Slide 38

Page 39: PMIT-6102 Advanced Database Systems

Thank You

Slide 39