You are on page 1of 7

The solution of assignment I for Distributed

Databases
Student : Hongzhi Li
Student Number:6782074
Professor: Dr. Yangjun Chen

Solution 1 for 5.1


(a) We horizontally partition the relation EMP (Figure 1) respect to { p1, p2}.
Where P1: TITLE>” Programmer” and P2: TITLE<”Programmer”.
EMP
ENO ENAME TITLE
E1 J. Doe Elect. Eng
E2 M. Smith Syst. Anal.
E3 A. Lee Mech. Eng
E4 J. Miller Programmer
E5 B. Casey Syst. Anal.
E6 L. Chu Elect. Eng
E7 R. Davts Mech. Eng
E8 J, Jones Syst. Anal.

Figure 1

We can get two fragments EMP1 and EMP2

EMP1
ENO ENAME TITLE
E1 J. Doe Elect. Eng
E3 A. Lee Mech. Eng
E6 L. Chu Elect. Eng
E7 R. Davts Mech. Eng
EMP2
ENO ENAME TITLE
E2 M. Smith Syst. Anal.
E5 B. Casey Syst. Anal.
E8 J, Jones Syst. Anal.

(b) EMP1 and EMP2 do not fulfill the completeness rule of fragmentation.
The reason is the item ( E4, J. Miller, Programmer) of EMP does not
appear in either EMP1 or EMP2 fragments.
(c) We can modify the simple predicates P1 as: TITLE<=” Programmer”, P2:
TITLE>”Programmer”. So Pr is {p1, p2}. Based on the Pr, the domain of
TITLE is {<= Programmer, >Programmer}. The implications I contains two
implications, they are: i1: p1=>¬ p2 and i2: ¬ p1=> p2.
The following four minterm predicates are defined according to Pr.
m1: p1 Λ p2 m2 : p1 Λ ¬p2 m3: ¬ p1 Λ p2 m4: ¬ p1 Λ¬p2
In this case the minterm predicates m1 and m4 are contradictory to the
implications I and can therefore be eliminated from M. So we can get the
minterm predicates: m2: TITLE<=” Programmer”
M3: TITLE>”programmer”
Therefore, we define two fragments Fs ={S1, S2} according to M.

S1
ENO ENAME TITLE
E1 J. Doe Elect. Eng
E3 A. Lee Mech. Eng
E4 J. Miller Programmer
E6 L. Chu Elect. Eng
E7 R. Davts Mech. Eng

S2
ENO ENAME TITLE
E2 M. Smith Syst. Anal.
E5 B. Casey Syst. Anal.
E8 J, Jones Syst. Anal.
Figure 2
Correctness:
1) Completeness:
The set of simple predicates Pr={p1, p2} is completeness because the tuples
of S1 and S2 have same probability of being accessed by the applications of
TITLE<= “Programmer” and TITLE>”Programmer”. Also, the Pr is minimal.
Because p1 and p2 are mutual, ti  S1 => ti  S2. So the simple predicates (p1
and p2) are relevant. The Pr is minimal.
2) Reconstruction:
Reconstruction of the global relation can be performed by the union operator.
3) Disjointness: From Figure 2, we can know that S 1 and S2 are mutually
exclusive.
Solution 2 for 5.5:
In this case we can horizontally partition the PAY relation to two fragments
PAY1 and PAY2 according to Pr={ p1: SAL<30000, p2: SAL≥3000}.
We can get minterm predicates M as following:
m1: p1 Λ p2 m2 : p1 Λ ¬ p2 m3: ¬ p1 Λ p2 m4: ¬ p1 Λ¬ p2
The implications are as: ¬ {p1: SAL<30000}=> {SAL≥30000}
¬ {p2:SAL≥3000}=>{SAL<3000}
So, M is :
m1: p1 Λ p2 =>{SAL<30000} Λ{SAL≥3000}
m2 : p1 Λ ¬ p2=>{SAL<30000} Λ{SAL<3000}=>{SAL<3000}
m3: ¬ p1 Λ p2 =>¬ {SAL<30000} Λ{SAL≥3000}=>
{SAL ≥30000} Λ{SAL≥3000}=>{SAL≥30000}
m4: ¬ p1 Λ¬ p2 => ¬ {SAL<30000} Λ¬ {SAL≥3000}=>
{SAL≥30000} Λ{SAL<3000}
we can delete m2 and m4. Base m1 and m3, we can horizontally partition PAY
relation as following:
PAY1 PAY2
TITLE SAL
Mech. Eng 27000
Programmer 24000
TITLE SAL
Elect. Eng 40000
Syst. Anal 34000

Figure 3
When we produce the derived horizontal fragments of EMP relation, we base
on the semijoin predicate between PAY and EMP.
This is EMP.TITLE= PAY.TITLE. We get the derived horizontal fragments of
EMP with respect to PAY.
EMP1 EMP2
ENO ENAME TITLE
E3 A. Lee Mech. Eng
E4 J. Miller Programmer
E7 R. Davis Mech. Eng
ENO ENAME TITLE
E1 J. Doe Elect. Eng
E2 M. Smith Syst. Anal
E5 B. Casey Syst. Anal
E6 L. Chu Elect. Eng
E8 J. Jones Syst. Anal
1) Completeness: The TITLE is the join attribute between the owner (PAY)
and the member (EMP). Because each tuple t of EMP, there are a tuple t’of
PAY. Hence, the horizontal derived fragments are completeness.
2) Reconstruction:
Reconstruction of the global relation can be performed by the union operator.
3) Disjointness:
In Figure 3. the minterm predicates M={ m1,m3} were
m1: {SAL<30000} Λ {SAL≥3000};
m3: SAL≥30000.
Since m1 and m3 are mutually exclusive, the fragmentation of PAY is disjoint.
For relation EMP, we require;
a. Each employee has a signal title
b. Each title has a single salary value associated with it.
These two rules follow from the semantics of the database, the fragmentation
of EMP with respect to PAY is also disjoint.

Solution 3 for 5.6


Based on the
aff ( Ai , A j )    ref (q )acc ( q ) , we can calculate the
qk accessAi andA j sites
l k l k

affinity matrix AA is:


aff(A1, A1)=5*1+10*1+35*1+5*1+15*1=70
aff(A1, A2)=5*1+10*1+15*1=30
aff(A1, A3)=5*1+10*1+15*1=30
aff(A1, A4)=35*1+5*1=40
aff(A1, A5)=5*1+10*1+35*1+5*1=55
aff(A2, A1)= aff(A1, A2)=30
aff(A2, A2)=10*1+20*1+5*1+10*1+15*1=60
aff(A2, A3)=10*1+20*1+5*1+10*1+15*1=60
aff(A2, A4)=0
aff(A2, A5)=10*1+20*1+5*1+10*1=45
aff(A3, A1)= aff(A1, A3)=30
aff(A3, A2)= aff(A2, A3)=60
aff(A3, A3)=10*1+20*1+5*1+10*1+10*1+15*1=70
aff(A3, A4)=0
aff(A3, A5)=10*1+20*1+5*1+10*1=45
aff(A4, A1)= aff(A1, A4)=40
aff(A4, A2)= aff(A2, A4)=0
aff(A4, A3)= aff(A3, A4)=0
aff(A4, A4)=35*1+5*1=40
aff(A4, A5)=35*1+5*1=40
aff(A5, A1)= aff(A1, A5)=55
aff(A5, A2)= aff(A2, A5)=45
aff(A5, A3)= aff(A3, A5)=45
aff(A5, A4)= aff(A4, A5)=40
aff(A5, A5)=10*1+20*1+5*1+10*1+35*+5*1=85
So we get the AA matrix as following.

A1 A2 A3 A4 A5 A1 A2
70 30 30 40 55 70 30
30 60 60 0 45 30 70
AA= 30 60 70 0 45 CA= 30 60
40 0 0 40 40 40 0
55 45 45 40 85 55 45

Consider the matrix AA. Based on BEA algorithm, we initialize CA as the


above. Then we follow the formula:
cont ( Ai , Ak , Aj )  2bond ( Ai , Ak )  2bond ( Ak , Aj )  2bond ( Ai , Aj ) where
n
bond ( Ax , Ay )   aff ( Az , Ax )aff ( Az , Ay ) , we calculate the contribution to the
z 1

global affinity measure of each alternative.

cont(A0, A3, A1)= 2bond(A0, A3)+2bond(A3, A1)-2bond(A0, A1)


=0+2*(30*70+60*30+70*30+0+45*55)-0=16950
cont(A1, A3, A2)=2bond(A1, A3)+2bond(A3, A2)-2bond(A1, A2)
=2*8475+2*10725-2*8175=22050
cont(A2, A3, A4)= 2bond(A2, A3)+2bond(A3, A4)-2bond(A2, A4)
=2*10725+2*0-2*0=21450
From the above results, we place A3 on between A1 and A2. The we get

A1 A3 A2
70 30 30
30 60 60
CA= 30 70 60
40 0 0
55 45 45
We compute other contributions of the other alternatives.
cont(A0, A4, A1)= 2bond(A0, A4)+2bond(A4, A1)-2bond(A0, A1)
=2*0+2*6600-2*0=13200
cont(A1, A4, A3)= 2bond(A1, A4)+2bond(A4, A3)-2bond(A1, A3)
=2*6600+2*3000-2*8475=2250
cont(A3, A4, A2)= 2bond(A3, A4)+2bond(A4, A2)-2bond(A3, A2)
=2*3000+2*3000-2*10725= -9450
cont(A2, A4, A5)= 2bond(A2, A4)+2bond(A4, A5)-2bond(A2, A5)
=2*3000+2*0-2*0=6000
So we place A4 on the left of the A1.
A4 A 1 A3 A 2
40 70 30 30
0 30 60 60
CA= 0 30 70 60
40 40 0 0
40 55 45 45
cont(A0, A5, A4)= 2bond(A0, A5)+2bond(A5, A4)-2bond(A0, A4)
=2*0+2*7200-2*0=14400
cont(A4, A5, A1)= 2bond(A4, A5)+2bond(A5, A1)-2bond(A4, A1)
=2*7200+2*12825-2*6600=26850
cont(A1, A5, A3)= 2bond(A1, A5)+2bond(A5, A3)-2bond(A1, A3)
=2*12825+2*11325-2*8475=31350
cont(A3, A5, A2)= 2bond(A3, A5)+2bond(A5, A2)-2bond(A3, A2)
=2*11325+2*10875-2*10725=22950
cont(A2, A5, A6)= 2bond(A2, A5)+2bond(A5, A6)-2bond(A2, A6)
=2*10875+2*0-2*0=21750

Finally, we get the CA

A4 A1 A5 A3 A2
 40 40 40 0 0 
 
 40 70 55 30 30

CA=  40 55 85 45 45 
 
 0 30 45 70 60 
 0 30 45 60 60 

Solution 4 for 6.7

The integrity constraint is

CHECK ON g:ASG, j:PROJ (SUM (g.DUR Where g.PNO=j.PNO))<48.

The compiled assertions associated with this constraint are


( ASG, INSERT, C1 ), (ASG, MODIFY, C2 )
where C1 is :
NEW  ASG  , g  ASG, j  PROJ : (( SUM NEW .DUR where NEW .PNO  j.PNO ) 
( SUM g .DUR where NEW .PNO  g .PNO ))  48
C2 is
NEW  ASG  , OLD  ASG  , g  ASG , j  PROJ :
((SUM (NEW . DUR )where ( NEW .PNO  j.PNO )  SUM ( g .DUR ) where (g.PNO  NEW . PNO ))
( SUM (OLD.DUR ) where NEW .PNO  OLD.PNO )  48

You might also like