Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Group Members

• Ahsan Naeem
• Muhammad Shahzad
• Arooba Saleem

TOPICS

• TRANSACTION
• CONCURRENCY IN DBMS
• DATABASE BACKUP AND
RECOVERY
Transaction

Transaction refers to the a set of operation that are used for


performing a set of logical work.
Usually, a transaction means the data present in the database has
changed.
States of Transaction

1. Active
This is the state in which a transaction is being executed.
Thus, it is like the initial state of any given transaction.

2. Partially Committed
A transaction is in its partially committed state whenever
it executes the final operation.

3. Failed
In case any check made by a database recovery system
fails, then that transaction is in a failed state. Remember
that a failed transaction can not proceed further.

4. Aborted
In case any check fails, leading the transaction to a failed
state, the recovery manager then rolls all its write
operations back on the database so that it can bring the
DB (database) back to the original state (the state where it
actually was prior to the transaction execution).
A DB recovery module can actually select one of
these two operations after abortion.
• Re-start
• Kill The Transaction

5. Committed
We can say that a transaction is committed in case
it actually executes all of its operations
successfully. In such a case, all of its effects are
now established permanently on the DB system.
Transaction State Diagram
Transaction Properties

A C I
D
Atomicity Consistency Isolation Durability
Atomicity

• This is derived from “Atomic”, that means ‘One’ or


‘Single’.
• The tasks (SQL queries) executed inside a transactions,
should act as a single unit of work
• Either all or None

Consistency

• Just like any other SQL query, a transaction


must also follow the Database table constrains.
• If some constraint is failing due to the SQL
queries running in the transaction, then the
transaction should be failed.

Isolation

• Multiple transaction occur independently


without interference.
Durability

• The changes of a
successful transaction
occurs even if the
system failure occurs.
Concurrency Control in DBMS

In concurrency control ,the multiple transactions can be


executed simultaneously without conflicting with each other.

Problems of Concurrency Control in DBMS;


 Lost Updates
 Dirty Reads
 Unrepeatable Reads
Lost Updates:
Lost updates occur when two or more
transactions attempt to update the same
data simultaneously, and the updates of one
transaction overwrite the changes made by
another transaction. As a result, the changes
made by one transaction are lost. This
problem can lead to incorrect data and
inconsistent results.
Dirty Reads:

A dirty read occurs when one transaction reads


data that has been modified by another
transaction that has not yet been committed. If
the transaction that made the changes is rolled
back, the data read by the other transaction
becomes invalid, leading to inconsistencies.
Unrepeatable Reads:

An unrepeatable read happens when a


transaction reads the same data twice
during its execution, but the data has
been modified by another transaction in
between. As a result, the two reads
yield different values, causing
inconsistency in the transaction's results
Some Common Techniques used in
Concurrency Control

 Locking
 Shared Locks
 Exclusive Locks
 Multi-version Concurrency Control
 Timestamp Ordering
Lock-Based Concurrency
Control

Lock-based concurrency control works


by allowing a transaction to acquire a
lock on a data item before accessing or
modifying it. Once a transaction
acquires a lock on a data item, other
transactions are prevented from
accessing or modifying that item until
the lock is released.
Multi-version Concurrency
Control

MVCC creates multiple versions of a data


item to allow different transactions to
operate on the data simultaneously without
interfering with each other.
Timestamp Ordering

Timestamp ordering works by comparing the


timestamps of transactions to determine their
execution order. Transactions with lower
timestamps are allowed to execute first,
while transactions with higher timestamps are
delayed.

You might also like