0% found this document useful (0 votes)
2 views10 pages

Adbms Imp Answer Chapter 5

The document discusses key concepts related to transactions in database management systems, including transaction operations (READ, WRITE, COMMIT, ROLLBACK) and states (Active, Committed, Failed, Terminated). It outlines the properties of transactions (Atomicity, Consistency, Isolation, Durability) and the challenges of concurrency control, such as the Lost Update Problem and Deadlock. Additionally, it describes various concurrency control methods like locking techniques and optimistic methods, as well as strategies for deadlock detection and prevention.

Uploaded by

harshbarot2177op
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

Adbms Imp Answer Chapter 5

The document discusses key concepts related to transactions in database management systems, including transaction operations (READ, WRITE, COMMIT, ROLLBACK) and states (Active, Committed, Failed, Terminated). It outlines the properties of transactions (Atomicity, Consistency, Isolation, Durability) and the challenges of concurrency control, such as the Lost Update Problem and Deadlock. Additionally, it describes various concurrency control methods like locking techniques and optimistic methods, as well as strategies for deadlock detection and prevention.

Uploaded by

harshbarot2177op
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

ADBMS IMP ANSWER GAURAV (158)

CHAPTER 5

1.​ Explain transaction, transaction operation and


transaction state.

A.​ Translation is a set database operation that


performs a particular task.

Following is the transaction operation :


i) READ,
ii) WRITE,
iii) COMMIT &
iv) ROLLBACK

Following is the transaction state :-

Active :
This is the initial state.
The Transaction stays in this state while it is
executing.
Various read and write operations are performed on
the database.
Particular Commit : ​
This is the state after the final statement of the
Transaction is executed.

Failed:
After the discovery that normal execution can no
longer proceed.

Committed:
The state after successful completion of the
Transaction.
It can be ensured that it will never be aborted.

Terminated:
Transaction enters in this state either from
committed or from aborted state.
Information about the Transaction is stored in the
system tables.

2.​ Explain transaction properties.

A.​ Transaction remains in consistent state for that it


must have following four properties:
Atomicity,
Consistency,
Isolation &
Durability.

Atomicity :-
Atomicity means that a transaction might be either
committed or will not be committed.
If the transaction is not committed then it will restart
from the start.

Consistency :-
Before the transaction starts and after it completes
the starting and the ending production should be
the same.

Isolation :-
Isolation means that multiple transactions are done
parallelly.
Which means that one transaction doesn’t affect
another transaction.

Durability :-
Durability means the guarantee that once a
transaction is successfully committed, the changes
made to the database are permanently stored and
will remain so, even if the system experiences failures
occur.

3.​ Explain concurrent control and problem with it.

A.​When more than one user is accessing the same


data at the same time then it is known as concurrent
access.

The technique used to protect data when multiple


users are accessing it concurrently is called
concurrency control.

Need/problem of concurrency control​

If transactions are executed serially, i.e., sequentially


with no overlap in time, no Transaction concurrency
exists.

However, if concurrent Transactions with interleaving


operations are allowed in an uncontrolled manner,
some unexpected, undesirable result may occur.
The main three problems of concurrency control are
as given below:
The Lost Update Problem
The Dirty Read Problem
The Inconsistent Retrieval Problem

4.​ Explain schedule and its type. Explain serializable


schedule.

A.​A scheduler is an in-built module of DBMS software


which determines the correct order of execution of
operations of multiple Transactions.

It ensures that the CPU is utilized in an efficient way. ​

Types of Schedules Schedules can be classified as


given below:
1) Complete Schedule
2) Non-Complete Schedule
3) Serial Schedule
4) Non-Serial Schedule

1) Complete Schedule :
If a schedule contains either COMMIT or ROLLBACK
actions for each Transaction.
It is known as Complete Schedule.

2) Non-Complete Schedule If a schedule does not


contain either COMMIT or ROLLBACK actions for
each Transaction.
It is known as a Non-Complete Schedule.

3) Serial Schedule If actions of concurrent


Transactions are not interleaved the schedule is
called non-serial schedule.
4) Non-Serial Schedule If actions of concurrent
Transactions are interleaved the schedule is called
non- serial schedule.

A schedule S’ is a serializable schedule if there exists


some serial schedule S such that S’ is equivalent to S.

The result produced by a serializable schedule is the


same as if the Transactions are executed serially.

The purpose of a serializable schedule is to improve


the performance of the system.

It is important in multi-user where several


Transactions are likely to be executed concurrently.

5.​ Explain concurrency control method.

A.​ Locking Methods​


A lock is a variable associated with the data item
which controls the access of that data item. ​

Lock prevents access of the data item to second ​

Transaction until first Transaction has completed the
use of that data item. ​

Lock Granularity ​

The size of a data item, chosen as the unit of
protection by a concurrency control technique is
called granularity. ​

A lock granularity indicates the level of lock to use. ​

Different level of locks is given below: ​

1) Database Level ​
2) Table Level ​
3) Page Level ​
4) Row Level​
5) Attribute Level ​

Lock Types DBMS mainly uses following type of
locking techniques: ​
1) Binary Locking ​
2) Shared/Exclusive (or Read/Write)Locking ​
3) Two-Phase Locking (2PL)


Time-stamp Method for Concurrency Control :​
A time-stamp is a unique identifier used to identify
the relative starting time of aTransaction.

This method uses either system time or logical
counter to be used as a time-stamp. ​

A time-stamp for Transaction T is denoted by TS(T). ​

To implement this time stamping, following two
time-stamp values are associated with each data
item.

W-Timestamp (X) Write time-stamp of data-item X is


denoted by W-timestamp(X).​

It specifies the largest timestamp of any Transaction
that executes write (X) successfully.​

R-Timestamp (X) Read time-stamp of data-item X is
denoted by R-timestamp(X). ​

It specifies the largest timestamp of any Transaction
that executes Read (X) successfully. ​

The timestamp ordering protocol ensures that any
conflicting Read and Write operations are executed
in timestamp order. ​

This method operates as follow: ​

1) If Transaction Ti issues Read (X) operation: ​

a. If TS(Ti) < W-timestamp (X) Then, Ti needs to read a
value of X that was already overwritten. ​

Hence, the read operation is rejected, and Ti is rolled
back. ​

b. If TS(Ti) ≥ W-timestamp (X) Then, the read operation
is executed, and R-timestamp(X) is set to the
maximum of R-timestamp(X) and TS(Ti). ​

2) If Transaction Ti issues Write (X) operation: ​

a. If TS(Ti) < R-timestamp(X) Then, the value of X that
Ti is producing was needed previously, and the
system assumed that that value would never be
produced.

Hence, the write operation is rejected, and Ti is rolled


back.

b. If TS(Ti) < W-timestamp(X) Then, Ti is attempting to


write an obsolete (out-dated) value of X.​

Hence, this write operation is rejected, and Ti is
rolled back.

c. Otherwise, the write operation is executed, and


W-timestamp(X) is set to TS(Ti).

Optimistic Method for Concurrency Control ​



In this method assume that conflicts are very rare. ​

It allows Transaction to run completely.​

And it checks for conflicts before they commit. ​

It is also known as a validation or certification
method. ​

Execution of Transaction Ti is done in three phases.
1) Read Phase 2) Validation Phase 3) Write Phase ​

1) Read Phase ​
The Transaction reads input values from the
database, performs computation and records the
updates in a temporary local variable that is not
accessed by other Transactions

2) Validation Phase ​

Transaction Ti performs a ``validation test'' to
determine if local variables can be written without
violating serializability. ​

If the test is positive, then Transaction goes to the
write phase otherwise changes are discarded and
Transaction Ti is restarted.
3) Write Phase

In this phase changes, recorded in local variables


are permanently applied to the database.

6.​ Define deadlock and ways to prevent deadlock.

A.​A set of Transactions is deadlocked, if each


Transaction in the set is waiting for a lock held by
some other Transaction in the set.

All the Transactions will continue to wait forever.

Example: ​

Transaction-A has obtained lock on X and is waiting
to obtain lock on Y. Transaction-B has obtained lock
on Y and is waiting to obtain lock on X.

But none of them can execute further.

Deadlock Detection and Deadlock Prevention:

Deadlock Detection
This technique allows deadlock to occur but then it
detects it and to solve it.
If a deadlock is detected, one of the Transactions
involved in the deadlock cycle is aborted.

Other Transactions continue their execution. An


aborted Transaction is rolled back and restarted.

Deadlock Prevention

This technique prevents a deadlock from occurring.

It requires that all Transactions lock all data items


they need in advance.

But if any of the locks cannot be obtained, a


Transaction will be aborted.

All the locks obtained are released and a


Transaction will be rescheduled.

This technique ensures that a Transaction never


needs to wait for any lock during its execution time
period.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy