You are on page 1of 5

LOVELY PROFESSIONAL UNIVERSITY

Homework Title/No. : ____4____ Course Code: ____CSE (301) _______

Course Instructor: Lect. Chavi Ralhan Course Tutor (if applicable):_______

Date of Allotment: Date of submission: 19th April 2011

Student’s Roll No. :__A12____ Section No. :____C1801______

Declaration :

I declare that this assignment is my individual work. I have not copied from any other
student’s work or from any other source except where due acknowledgement is made
explicitly in the text, nor has any part been written for me by another person.

Student’s Signature: MANISHA

Evaluator’s comments :

_________________________________________________________________________
__

Marks obtained :______________________ out of _________________________

Content of Homework should start from this page only:

PART-A

Question 1: Why there is a need of concurrency protocols when we have the


serializability concept?

Ans; - concurrency protocols are used to maintain database in a consistent state when
multiple transaction executed at the same time. Lock-based protocol, timestamp protocol,
validation protocol and multiple granularities are the concurrency control protocols. In a
serializability concept, concurrency protocols play important role. When transactions are
executed in serial manner, no transaction concurrency exists. However, if concurrent
transactions with interleaving operations are allowed in an uncontrolled manner, then some
undesirable result may occur that are follows as:-
• When the other transaction writes a second value of data on top of a first
value that is written by a first concurrent transaction then the transactions
that have read the wrong value end with incorrect results. Thus, updation
problem is occurred.
• When transaction read a value that has been aborted later then this value
removed from database and should not have read by any transaction. Hence,
the read problem is occurred and incorrect result produced.

To avoid these problems we need concurrency protocols in serialibility concept.

Question 2: “Thomas write rule modifies the time-stamp ordering protocol”. Do you
agree? Justify your answer.

Ans: - Yes, I agree with this statement “Thomas write rule modifies the timestamp
ordering protocol”. Thomas write rule is the modification of time- stamp ordering protocol
which is further example of time stamp based protocol. In Thomas write rule, the
transactions have same issues of read operation that are in time oriented protocol.

Let us assume that transactions T issues read operation on data item (A). Then following
conditions are :-

• If TS(T) < W-Timestamp(A) then, T is trying to read a value of A that was already
overwritten, hence transaction was abort read operation and T is rolled back.
• If TS(T) ≥ W-Timestamp(A) then, execute the read operation .
Set R-Timestamp (A)=Max(R-Timestamp(A),TS(T)).
Let us assume that transactions T issues write operation on data item (A). Then following
conditions are:-

• If TS (T) < W-Timestamp (A) then, abort write operation and rollback T.
• If TS (T) < W-Timestamp (A) then, write operation ignored.
• While execute write operation and set the value of W-Timestamp(A) as TS(T)

Question 3. Why we term validation based protocol optimistic protocol? Explain the
protocol with concurrent transactions?

Ans:- validation based protocol is the type of concurrency protocol. It process in three
phases these are:-

• Read phase:- transaction reads the data item from database and store into
local variable in this phase.
• Validation phase:- it performs some validation test to check whether the
modified values can be copied into the actual database consistently or not.

• Write phase:- after the validation phase successfully completed, then all
modified values are reflected to actual database and database can be updated with
new values.

Validation based protocol is also termed as optimistic protocol because optimistic


concurrency protocol there are no checking is done while the transaction is executing.
Modifications are not done in this protocol. All modifications are applied to local
variables of the data items in the transaction during transaction execution phase. After
this, validation phase comes and it checks whether any transaction’s updates are
serializable or not. If serializability is not violated, the transaction is committed and the
database is updated from the local copies; otherwise, the transaction is aborted and then
restarted again.

Question 4: Do we need recovery in database management system. Justify your answer


with techniques which you will use.

Ans:- YES, we need recovery system in database management system. Recovery


mechanism is useful to maintain the data in a consistent state when some failure occurred in
transaction ad some system failure. Failure may cause data loss. To avoid these problems
we need recovery mechanism in database management system. I will use log based
recovery and shadow paging technique to recover the database if some failure occurred due
to some logical errors. Log based recovery is used to maintain all records of the
modification that are needed to be done in the databases. These records are stored in the
log. Two schemes are used in the log based recovery that are: - 1) deferred log based
recovery 2) immediate log based recovery.

Question 5: Assume that the Railway reservation system is implemented using an


RDBMS. What are the concurrency control measures one has to take, in order to avoid
concurrency related problems in the above system? How can the deadlock be avoided in
this system?

Ans; - let us assume that the railway reservation system is implemented using an RDBMS
then we deal with concurrency control. Concurrency control mechanism is used to
maintain the database in a consistent state when improper way of data is produced while
insertion, updation and deletion operation is applied. It can be maintained by two
mechanisms these are:-

• Transactions: - Transaction is defined as a logical unit of work .Transaction is used


to maintain the integrity of a database while running multiple concurrent
operations. Transaction has ACID properties i.e. atomicity, consistency, integration
and durability. Transactions are said to be serializable iff it produces the same
desired result as some arbitrary serial execution of those same transactions for
arbitrary input.

• Locks. Lock is a variable that are associated each data item which tell the status of
any data item whenever any operations applied on it. There can be several different
types of resources that can be locked and several different ways of locking those
resources. Most locks used on Teradata resources that are automatically
locked. The Teradata lock manager implicitly locks the following objects
such that relation, view and database. There are four different levels of locking on
this resource that are applied by user these are: - read, write, exclusive and access.
B y d e f a u l t , T h e Teradata resources RDBMS applies most of its locks.

Deadlock occurred when each transaction is waiting for requested lock that is held by
another transaction. to handle the deadlock, there are three possible techniques applied
these are :-

• Deadlock prevention

• Deadlock detection and recovery

• Time-out based scheme

Question 6: “Shadow paging uses the concept of paging scheme (in operating system)”.
Do you agree? Justify your answer.

Ans:- Yes, I agree with this statement that shadow paging uses the concept of paging. As
paging scheme divides the logical memory into pages and physical memory into frames,
shadow paging process is same but the difference is that it divides the database into pages
and it treats the physical memory into frames. The mapping of database to physical
memory is done by two page table:- 1) current page table is to store the records of all
database modification 2) shadow page table is used to restore the old values of data if
some failure occurred in a transaction. after transaction commit, then shadow page table is
return to the pool of free blocks and all the modifications that are done in current page table
is reflected to actual database. This is the concept of shadow paging.

You might also like