0% found this document useful (0 votes)
10 views20 pages

Distributed Database Managment System

The document discusses concurrency control in database management systems. Concurrency control is needed to manage simultaneous transactions accessing shared data to prevent inconsistencies. It describes problems that can occur like lost updates, dirty reads, and unrepeatable reads. Common concurrency control protocols are discussed at a high level, including lock-based protocols using shared and exclusive locks, timestamp ordering protocols, and validation-based optimistic concurrency control protocols.

Uploaded by

Muhammad Arslan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
10 views20 pages

Distributed Database Managment System

The document discusses concurrency control in database management systems. Concurrency control is needed to manage simultaneous transactions accessing shared data to prevent inconsistencies. It describes problems that can occur like lost updates, dirty reads, and unrepeatable reads. Common concurrency control protocols are discussed at a high level, including lock-based protocols using shared and exclusive locks, timestamp ordering protocols, and validation-based optimistic concurrency control protocols.

Uploaded by

Muhammad Arslan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 20

Distributed Database managment system

❖Submitted to:
Sir Zubair
❖Submitted by:
Maham (1922) Nimrah(1921) Tayyaba(1914)
Naima(1953) Iqra(1917) Kashaf (1929)
❖Topic:
Concurrency Control
Content
✓ Defination
✓ Example
✓ Conccurent Execution in DBMS
✓ Problems
✓ Protocols
Defination:

Concurrency control concept comes under


the Transaction in database management system (DBMS).
“It is a procedure in DBMS which helps us for the
management of two simultaneous processes to execute
without conflicts between each other, these conflicts occur in
multi user systems”
➢ Concurrency can simply be said to be executing multiple
transactions at a time. It is required to increase time
efficiency. If many transactions try to access the same
data, then inconsistency arises. Concurrency control
required to maintain consistency data.
➢ Example:
For example, if we take ATM machines and do not
use concurrency, multiple persons cannot draw money at a
time in different places. This is where we need concurrency.
➢Concurrent Execution in DBMS:
In a multi-user system, multiple users can access and use
the same database at one time, which is known as the concurrent
execution of the database. It means that the same database is executed
simultaneously on a multi-user system by different users.
The thing is that the simultaneous execution that is
performed should be done in an interleaved manner, and no operation
should affect the other executing operations, thus maintaining the
consistency of the database. Thus, on making the concurrent execution of
the transaction operations, there occur several challenging problems that
need to be solved.
➢ Problems with Concurrent Execution:
In a database transaction, the two main operations
are READ and WRITE operations.
So, there is a need to manage these two operations in
the concurrent execution of the transactions as if these operations
are not performed in an interleaved manner, and the data may
become inconsistent. So, the following problems occur with the
Concurrent Execution of the operations:
1. Lost Update Problems (W - W Conflict)
2. Dirty Read Problems (W-R Conflict)
3. Unrepeatable Read Problem (W-R Conflict)
➢ Lost Update Problems (W - W Conflict)
The problem occurs when two different database
transactions perform the read/write operations on the same
database items in an interleaved manner (i.e., concurrent
execution) that makes the values of the items incorrect hence
making the database inconsistent.
➢ Example:
Consider the below diagram where two transactions TX and
TY, are performed on the same account A where the balance of
account A is $300.
Lost Update Problems (W - W Conflict)
➢ Dirty Read Problems (W-R Conflict)
The dirty read problem occurs when one transaction
updates an item of the database, and somehow the transaction
fails, and before the data gets rollback, the updated database item
is accessed by another transaction. There comes the Read-Write
Conflict between both transactions.
➢ Example:
Consider two transactions TX and TY in the below
diagram performing read/write operations on account A where the
available balance in account A is $300:
Dirty Read Problems (W-R Conflict)
➢ Unrepeatable Read Problem (W-R Conflict)
Also known as Inconsistent Retrievals Problem that
occurs when in a transaction, two different values are read for the
same database item.
➢ Example:
Consider two transactions, TX and TY, performing the
read/write operations on account A, having an available balance =
$300. The diagram is shown below
Unrepeatable Read Problem (W-R Conflict)
➢ Concurrency Control Protocols:
The concurrency control protocols ensure the atomicity,
consistency, isolation, durability and serializability of the
concurrent execution of the database transactions. Therefore, these
protocols are categorized as:
1. Lock Based Concurrency Control Protocol
2. Time Stamp Concurrency Control Protocol
3. Validation Based Concurrency Control Protocol
➢ Lock-Based Protocol:
In this type of protocol, any transaction cannot read or
write data until it acquires an appropriate lock on it. There are two
types of lock.
1. Shared lock
2. Exclusive lock
➢ Shared lock:
It is also known as a Read-only lock. In a shared lock, the
data item can only read by the transaction.
It can be shared between the transactions because when the
transaction holds a lock, then it can't update the data on the data
item.
➢ Exclusive lock:
In the exclusive lock, the data item can be both reads as
well as written by the transaction.
This lock is exclusive, and in this lock, multiple transactions do not
modify the same data simultaneously.
➢ Timestamp Ordering Protocol:
The Timestamp Ordering Protocol is used to order the
transactions based on their Timestamps. The order of transaction
is nothing but the ascending order of the transaction creation.
The priority of the older transaction is higher that's why it
executes first. To determine the timestamp of the transaction, this
protocol uses system time or logical counter.
The lock-based protocol is used to manage the order
between conflicting pairs among transactions at the execution
time. But Timestamp based protocols start working as soon as a
transaction is created.
Let's assume there are two transactions T1 and T2.
Suppose the transaction T1 has entered the system at 007 times and
transaction T2 has entered the system at 009 times. T1 has the
higher priority, so it executes first as it is entered the system first.
The timestamp ordering protocol also maintains the
timestamp of last 'read' and 'write' operation on a data.
➢ Validation Based Protocol:
Validation phase is also known as optimistic
concurrency control technique. In the validation based protocol,
the transaction is executed in the following three phases.
1. Validation Phase
2. Read phase
3. Write phase
➢ Validation phase:
In this phase, the temporary variable value will
be validated against the actual data to see if it violates the
serializability.
Validation phase has the following timestamps
➢ Validation (Ti):
It contains the time when Ti finishes its read phase
and starts its validation phase.
➢ Read phase:
In this phase, the transaction T is read and
executed. It is used to read the value of various data items and stores
them in temporary local variables. It can perform all the write
operations on temporary variables without an update to the actual
database.
Read Phase has following timestamp.
➢ Start(Ti):
It contains the time when Ti started its execution.
➢ Write phase:
If the validation of the transaction is validated,
then the temporary results are written to the database or system
otherwise the transaction is rolled back.
Write Phase has following timstamp.
➢ Finish(Ti):
It contains the time when Ti finishes its write phase.
THANKS FOR WATCHING

You might also like