You are on page 1of 3

CHERUIYOT M GILBERT

C025-01-0485/2013
ADVANCED DATABASE
CAT1

a) Consider the following three transactions


(i). Differentiate between a transaction and a schedule (2 marks)
Transaction is an executing program (process) that includes one or more database access
operations while a schedule is a plan for grouping transaction which access some data at the
same time
ii. Write two other schedules for the given transactions, one of which must be a serial
schedule (4 marks)
Time (t)
T1
T2
T3
T4
T5
T6
T7
T8
T9
T10
T11
T12
T13
T14
T15
T16

T1
R(X)
W(X)

Time (t)
T1
T2
T3
T4
T5
T6

T1

T2

T3

R(Y)
W(Y)
R(Z)
W(Z)
R(Y)
W(Y)
R(Z)
W(Z)
R(Y)
W(Y)
R(Z)
W(Z)
R(X)
W(X)

T2
W(X)

W(Z)
R(X)
W(X)

T3
R(Y)
R(Z)

T7
T8
T9
T10
T11
T12
T13
T14
T15
T16

R(X)
R(Z)
W(Y)
W(Z)
R(Y)
R(Z)
R(Y)
W(Y)
W(Y)
W(Z)

iii. Identify the conflicts in the above schedules (3 marks)


Between t12 and t13 there is a conflict, writing and reading y
Between t3 and t4 there is a conflict reading z and writing z

iv. By first outlining the procedure, test if the above schedule is conflict serializable.
(5 marks)
A schedule is conflict serializable if and only if its precedence graph is cyclic. Construct a
precedence graph and look for cycles which takes order n2 time, where n is the number of
vertices in the graph and n+e where e is the number of edges. If the precedence graph is cyclic
obtain the serializability order by topological sorting of the graph.
b) Giving examples, differentiate between Cascade less schedules and strict schedules (4
marks)
Cascade less-to attain this schedule ever transaction must read only commited.Refers to cases
where we have aborts. One where a rollback does not cascade to other transaction
T1
R(X)
W(X)
R(Y)
W(Y)
Abort
Roll back

T2

R(X)
W(X)
Commit

Strict schedules -A schedule is strict if overriding of uncommitted data is not allowed. Formally,
if it satisfies the following conditions:

Tj reads a data item X after Ti has terminated (aborted or committed)

Tj writes a data item X after Ti has terminated (aborted or committed)

Question Two (2)


a) Discuss two types of locks used in databases (4 marks)
(i)Binary lock has two states: Locked and Unlocked.If a database item X is locked, then
X cannot be accessed by any other database operation
(ii) Shared/Exclusive. It has three states: Read Locked , Write Locked and Unlocked
Several transactions can access the same item Y for reading (Shared Lock),
however writing requires a Write (Exclusive) Lock.
b) Locking does not guarantee correctness, discuss (4 marks)
Locking means that the transaction marks the data that it accesses that the DBMS know
not to allow other transactions to modify it until the first transaction succeed or fails. This
lock must always be acquired by processing data including data that is read but not
modified, on trivial transaction typically requires large no of locks resulting in substantial
overhead as well as blocking other transactions
c) Using examples explain two approaches to dealing with deadlocks (4 marks)
(i) Conservative approach- a transactions locks all data items it refers to before it begins
execution. This way deadlock is prevented since the transactions will never wait for a data item.
(ii) deadlock detection-deadlocks can be allowed to happen when they do the scheduler
which maintains a wait for graph will detect and resolve the deadlocks.in the wait graph a
deadlock is detected if a cycle is found.in this case one of the transaction is selected and routed
back ,the task therefore is to carefully select the victim. .
(iii)Wait-die and Wound-Wait
There are two schemes that utilize transaction timestamps. Wait-die (older transaction waits for
younger transaction) and Wound Wait (older transaction preempts younger transaction).

You might also like