You are on page 1of 6

Part 2). Provide graph, tree, etc. representation.

(20 points)
2.1) Produce a wait-for-graph (WFG) for the following transaction scenario in a
centralized database sste! and deter!ine whether deadloc" e#ists. ($ points)
Transaction Data items locked by transaction Data items that transaction is waiting for
T
1
#
2
#
1
% #
$
T
2
#
$
% #
10
#
&
% #
'
T
3
#
'
#
(
% #
)
T
4
#
&
#
1
T
5
#
1
% #
)
#
$
T
6
#
(
% #
*
#
+
T
7
#
+
#
)
Cycles in graph implies that deadloc e!ists.
"T2 #$ T4 #$ T5 #$ T2), "T2 #$ T3 #$ T5 #$ T2), "T2 #$ T3 #$ T6 #$ T7 #$ T5 #$ T2)
2.2) ,onsider fi-e transactions .
1
% .
2
% .
$
% .
(
% and .
)
with/
.
1
initiated at site 0
1
and spawning an agent at site 0
2
%
.
2
initiated at site 0
$
and spawning an agent at site 0
1
%
.
$
initiated at site 0
1
and spawning an agent at site 0
$
%
.
(
initiated at site 0
2
and spawning an agent at site 0
$
%
.
)
initiated at site 0
$
.
.he loc"ing infor!ation for these transactions is shown in following table.
() points)
T
2
T
3
T
1
T
4
T
5
T
6
T
7
#
$
#
1
#
&
#
'
#
(
#
)
#
1
#
$
#
+
#
)
(a) Produce the local wait-for-graphs (1WFGs) for each of the sites (si!ilar to
what is shown in e#a!ple 2$.1). What can ou conclude fro! the local WFGs2
Concl%sion& There is no local deadloc at any site.
(b) 3ber!arc"4s !ethod for distributed deadloc" detection is said to be !ore
robust than the abo-e !ethod and it wor"s as follows/
- adding an e#ternal node .
e#t
to the 1WFGs to indicates re!ote agent%
- if an 1WFG contains a ccle that does not in-ol-e .
e#t
% then the site and 55670
are in deadloc"%
- global deadloc" !a e#ist if 1WFG contains a ccle in-ol-ing .
e#t
and to
deter!ine if there is deadloc"% the graphs ha-e to be !erged.
Fro! the abo-e transactions% de!onstrate how 3ber!arc"4s !ethod wor"s. What
can we conclude fro! the global WFG2
T
1
T
2
T
3
T
1
T
4
T
2
T
3
T
4
T
5
'ite 1 'ite 2 'ite 3
#
1
#
)
#
$
Cycle at site 1 implies potential deadloc, so move ()* +rom site 1 to site 3. ,o-, -e no- that
T1 is -aiting on !. -hich is loced /y T4. Th%s, the res%lting ()* sho-s a cycle not involved
-ith Te!t&
-hich implies system is in glo/al deadloc and one o+ the transactions m%st /e selected to /e a/orted
and restarted.
2.$) (8 si!plified -ersion of the e#ercise on page &$2)
8 !ultinational engineering co!pan has decided to distribute its pro9ect !anage!ent
infor!ation at the regional le-el in !ainland 6ritain. .he current centralized relational
sche!a is as follows/
Employee (NIN, fName, lName, address, DOB, sex, salary, taxCode, deptNo)
Department (deptNo, deptName, managerNIN, businessAreaNo, regionNo)
Project (projNo, projName, contractrice, project!anagerNIN, deptNo)
WorksOn (NIN, projNo, "ours#or$ed)
Business (businessAreaNo, businessAreaName)
Region (regionNo, regionName)
0uppose the sub-regions ha-e been laid out according to the following predicates/
T
1
T
2
T
3
T
1
T
4
T
2
T
3
T
4
T
5
'ite 1 'ite 2 'ite 3
T
e!t
T
e!t
T
e!t
'
2
'
3
'
1
'
1
'
1
'
3
'
3
'
2
#
1
#
)
#
$
T
1
T
2
T
3
T
4
T
5
T
e!t
'
2
#
$
#
1
#
) #
'
0
region,o 1 1 "2'cotland3) and /%siness4rea,o 1 1 "2'53),
region,o 1 1 "2'cotland3) and /%siness4rea,o 1 2 "2653),
region,o 1 2 "2(ales3) and /%siness4rea,o 1 2 "2653),
region,o 1 3 "25ngland3) and /%siness4rea,o 1 1 "2'53),
region,o 1 3 "25ngland3) and /%siness4rea,o 1 2 "2653),
region,o 1 3 "25ngland3) and /%siness4rea,o 1 3 "2573)
8 (+ points)
(a) :se pri!ar horizontal frag!entation for relation Department, write relational
algebra for each frag!ent and show the relational algebra of how the original
relation to be reconstructed.
9ori:ontal +ragmentation can /e achieved /y selection operation.
;1&
region,o 1 1 and /%siness4rea,o 1 1
";epartment)
;2&
region,o 1 1 and /%siness4rea,o 1 2
";epartment)
;3&
region,o 1 2 and /%siness4rea,o 1 2
";epartment)
;4&
region,o 1 3 and /%siness4rea,o 1 1
";epartment)
;5&
region,o 1 3 and /%siness4rea,o 1 2
";epartment)
;6&
region,o 1 3 and /%siness4rea,o 1 3
";epartment)
9ori:ontal +ragments can /e reconstr%cted /y <nion operation.
=econstr%ction& ;1 ;2 ;3 ;4 ;5 ;6
(b) :se -ertical frag!entation for relation Employee, write relational algebra for each
frag!ent and show the relational algebra of how the original relation to be
reconstructed.
(e %se pro>ection operation ") to +ragment relation vertically. 5ach segment -ill
/e partitioned /y gro%ping relevant attri/%tes together and it has to incl%ding primary
ey. ?elo- is an e!ample o+ vertical +ragmentation on 5mployee.

5
1
& NIN, fName, lName, address, DOB, sex, deptNo(Employee)
5
2
& NIN, salary, taxCode(Employee)
@ertical +ragmentation can /e reconstr%cted /y >oin operation on primary ey as
sho-n /elo-&
=econstr%ction& 5
1
NIN 5
2
(c) :se deri-ed frag!entation for relation Projects based on sub-regions gi-en in (a)%
write relational algebra for each frag!ent and show the relational algebra of how
the original relation to be reconstructed.
;erived +ragmentation can /e o/tained /y 'emi#>oin operation. An this case, the
relation Projects -ill /e +ragmented according to attri/%te depart;o o+ ;
i
.
P
i
& Pro>ects deptNo
;
i
1 i 6
7ie hori:ontal +ragmentation, the original relation can /e achieved /y applying
<nion operation on derived +ragments&
=econstr%ction& "P
1
P
2
P
3
P
4
P
5
P
6
)
2.() Fro! the 5rea!<o!e relational sche!a% two of its relations are shown below/
Staff (staffNo, fName, lName, position, sex, DOB, salary, branc"No)
Branch(branc"No, address, street, city, %ipcode)
8ssu!ing the relations are frag!ented as followed/
B1/
branch;o=>600$4
(6ranch)
B2/
branch;o?=>600$4
(6ranch)
S1/
staff;o% position% se#% 536% salar
(0taff)
S2/
staff;o% f;a!e% l;a!e% branch;o
(0taff)
S
21
/
branch;o=>600$4
(0
2
)
S
22
/
branch;o?=>600$4
(0
2
)
0uppose a !anager at the head@uarter would li"e to list the staff na!es who wor" at
6ranch 600$ along with the cit na!e. .he 0A1 is written as/
SELECT f;a!e% l;a!e% cit
FROM 6ranch 6% 0taff 0
WHERE 6.branch;o = 0.branch;o 8;5 6.branch;o = >600$4B
0how the generic relational algebra tree for this @uer and gi-e the reduced tree.
(+ points)
(<int/ see e#a!ples 2$.2% 2$.$% and 2$.()
*eneric relational alge/ra tree
'
1
'
21
'
22
sta++,o

/ranch,o13?BB33
?
1
?
2

/ranch,o13?BB33

+,ame, l,ame, city

+,ame, l,ame, city


?
1
'
21

+,ame, l,ame, city


?
1
'
21
/ranch,o

/ranch,o, city

+,ame, l,ame, /ranch,o
?2, '1, and '22 do not contain data needed. There+ore,
they can /e eliminated.
Per+orm Pro>ection on the +ragments so that only
needed col%mns -ill /e sent over +or >oin operation.

You might also like