Вы находитесь на странице: 1из 10

Database Management System: Assignment 7

Total Marks : 20

April 1, 2019

Question 1
Which of these is/are false about transaction?

Marks: 2 MSQ

a) Multiple transactions can execute concurrently whether they are isolated or not.

b) If a transaction completes successfully, anything it changes in the database must persist


even if system failure occurs.

c) Either all operations of a transaction are executed properly or none.

d) After completion of the transaction database might be consistent or inconsistent.

Answer a), d)

Explanation:According to ACID properties of transaction, two transaction can execute


concurrently only if they are isolated. Hence option a) is false. After completion of transac-
tion, database must be consistent. Hence option d) is false.

1
Question 2
Choose the correct transaction life cycle among the following diagrams:
Marks: 2 MCQ

a)

b)

c)

d)

Answer: b)

Explanation: A transaction starts from active state and enters into partially committed
state as it continues its execution. From partially committed state, it may either change to
committed state by properly completing its execution, or it may fail and enter failed state and
is aborted then.

2
Question 3
Consider the following transaction schedules S1 and S2.

Choose the correct option that holds for the schedules S1 and S2.
Marks: 2 MCQ

a) S1 is serializable, S2 is non-serializable.

b) S1 is non-serializable, S2 is serializable

c) Both S1 and S2 are serializable.

d) Both S1 and S2 are non-serializable

Answer: a)
Explanation:
schedule S1: r1(A) w1(A) r2(B) w2(B) r1(B)
swap r2(B) and w1(A): r1(A) r2(B) w1(A) w2(B) r1(B)
swap r2(B) and r1(A): r2(B) r1(A) w1(A) w2(B) r1(B)
swap w2(B) and w1(A): r2(B) r1(A) w2(B) w1(A) r1(B)
swap w2(B) and r1(A): r2(B) w2(B) r1(A) w1(A) r1(B)
schedule S2: r1(A) w1(A) r2(A) w2(A) r1(A)
swapping r1(A) and w2(A) is not possible because read and write in two different
transactions occur on the same database(A).

3
Question 4
There are two schedules S1 and S2 with the same set of transactions. Which of the following
are incorrect for view serializability to occur.

Marks: 2 MCQ

a) If in schedule S1 , transaction Ti reads the initial value of (Q), then in schedule S2 also
transaction Ti must read the initial value of (Q).

b) If in schedule S1 transaction Ti executes(Q) and that value was produced by transaction


Tj , then in schedule S2 also transaction Ti must read the value of Q that was produced by
the same write(Q) operation of transaction Tj .

c) The transaction that performs the final write(Q) operation in schedule S1 must also per-
form the first write(Q) operation in schedule S2 .

d) The transaction that performs the final write(Q) operation in schedule S1 must also per-
form the final write(Q) operation in schedule S2 .

Answer: c)

Explanation: The conditions for view serializability are:

i) If in schedule S1 , transaction Ti reads the initial value of Q, then in schedule S2 also


transaction Ti must read the initial value of Q.

ii) If in schedule S1 transaction Ti executes(Q) and that value was produced by transaction
Tj , then in schedule S2 also transaction Ti must read the value of Q that was produced by
the same write(Q) operation of transaction Tj

iii) The transaction that performs the final write(Q) operation in schedule S1 must also
perform the final write(Q) operation in schedule S2 .
Hence option c) is false.

4
Question 5
Identify the options that are incorrect for view serializability and conflict serializability.

Marks: 2 MCQ

a) A schedule S is view serializable if it is view equivalent to a serial schedule.

b) Every view serializable schedule that is not conflict serializable has blind writes.

c) Every conflict serializable schedule is view serializable.

d) Every view serializable schedule is conflict serializable.

Answer: d)

Explanation: Every view serializable schedule may or may not be conflict serializable. So
option d) is incorrect.

5
Question 6
Given the following two transactions identify which is valid for the transaction T1 and T2

Marks: 2 MCQ

a) T2 follows Two phase locking protocol, T1 does not follow Two phase locking protocol.

b) T1 follows Two phase locking protocol, T2 does not follow Two phase locking protocol.

c) Both transactions T1 and T2 follow Two phase locking protocol.

d) Neither T1 nor T2 follow Two phase locking protocol.

Answer: b)

Explanation: Two phase locking protocol means a transaction will follow two phases-
Growing phase and Shrinking phase. In Growing phase, a transaction will acquire locks
but will not release any locks, while in Shrinking Phase a transaction will release locks but will
not acquire any locks. T1 follows this rule, because when it is acquiring locks, it is not releasing
any(Growing phase) and once it has started releasing locks it does not acquire any new lock
further(Shrinking phase). Whereas T2 after unlocking acquires new lock which disobeys Two
phase principle.

6
Question 7
Consider there are two schedules S1 and S2 as follows:

Identify the correct statement about which schedule suffers deadlock. Marks: 2 MCQ

a) Both S1 and S2 will suffer deadlock.

b) S1 will suffer deadlock, S2 will not suffer deadlock.

c) S2 will suffer deadlock, S1 will not suffer deadlock.

d) Neither S1 nor S2 will suffer deadlock.

Answer: c)

Explanation: In S1 , T2 has acquired shared lock on (B), and T1 wants to acquire shared
mode lock on (B). More than one transactions are allowed to acquire shared mode lock on
the same database, so shared mode lock on (B) is granted to T1 and no deadlock occurs in
S1 . But in S2 , T2 is holding exclusive mode lock on (B) and T1 has requested shared mode
lock on (B). While one transaction is holding exclusive mode lock on a particular database,
no other transaction can acquire any lock on that database unless the lock is released by the
former transaction (which is holding exclusive lock on the database). Unless transaction T1
gets shared mode lock on (B), it will not proceed with the next operations and will not release
the exclusive mode lock on (A), which restricts transaction T2 to acquire lock on (A). Both
T1 and T2 are waiting for each other to release resources. Hence S2 is going to suffer a deadlock.

7
Question 8
Identify the correct options about timestamp from the following:
Marks: 2 MSQ

a) Suppose Ti issues write(Q), then if TS(Ti )>R-timestamp(Q) then write operation is


rejected and Ti is rolled back.

b) Suppose Ti issues write(Q), then if TS(Ti )<R-timestamp(Q) then write operation is


rejected and Ti is rolled back.

c) Suppose Ti issues read(Q), then if TS(Ti ) <W-timestamp(Q) then read operation is


rejected and Ti is rolled back.

d) Suppose Ti issues read(Q), then if TS(Ti ) >W-timestamp(Q) then read operation is


rejected and Ti is rolled back.

Answer:b), c)

Explanation: If TS(Ti )<R-timestamp(Q) where Ti issues write(Q), then the values


of (Q) that Ti is producing was needed previously and the system assumed that the value will
never be produced and hence the write operation is rejected and Ti is rolled back. If Ti issues
a read(Q), and if TS(Ti )≤ W-timestamp(Q) then Ti needs to read a value of (Q) that was
already overwritten. Hence the read operation is rejected and Ti is rolled back.

8
Question 9
Consider the following two wait-for graphs.

Figure 1:

Figure 2:

Choose the option which stands valid for the above graphs.
Marks: 2 MCQ

a) Figure1 graph shows possibility of deadlock, Figure2 graph doesn’t show possibility of
deadlock.

b) Both graphs of Figure1 and Figure2 show possibility of deadlock

c) Neither graph of Figure1 nor Figure2 shows possibility of deadlock.

d) Figure1 graph does not show possibility of deadlock, Figure2 graph shows possibility of
deadlock.

Answer: d)

Explanation: Figure1 is a wait-for graph without a cycle, so it doesn’t shows possibility


of deadlock, while Figure2 wait-for graph has cycle, so it shows possibility of deadlock.

9
Question 10
Which of these is not a Transaction control language(TCL) command?:
Marks: 2 MCQ

a) ROLLBACK

b) UPDATE

c) COMMIT

d) SAVEPOINT

Answer: b)

Explanation: UPDATE is a Data Manipulation Language (DML) command and not a


Transaction control language (TCL) command.

10

Вам также может понравиться