0% found this document useful (0 votes)
28 views2 pages

Transactions Properties

Uploaded by

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

Transactions Properties

Uploaded by

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

concurrency

=====================================================
The running together of two transactions,
which may access the same database rows during overlapping time periods.
Such simultaneous accesses, called collisions, may result
in errors or inconsistencies if not handled properly. The more overlapping
that is possible, the greater the concurrency.
=====================================================
Concurrency Control in DBMS
Concurrency Control deals with interleaved execution of more than one transaction.
In the next article, we will see what is serializability and how to find whether a
schedule is serializable or not.

What is Transaction?

A set of logically related operations is known as transaction. The main operations


of a transaction are:

Read(A): Read operations Read(A) or R(A) reads the value of A from the database and
stores it in a buffer in main memory.

Concurrency Control deals with interleaved execution of more than one transaction.
In the next article, we will see what is serializability and how to find whether a
schedule is serializable or not.

What is Transaction?

A set of logically related operations is known as transaction. The main operations


of a transaction are:

Read(A): Read operations Read(A) or R(A) reads the value of A from the database and
stores it in a buffer in main memory.

W(A);

Assume A’s value before starting of transaction is 5000.


The first operation reads the value of A from database and stores it in a buffer.
Second operation will decrease its value by 1000. So buffer will contain 4000.
Third operation will write the value from buffer to database. So A’s final value
will be 4000.

But it may also be possible that transaction may fail after executing some of its
operations. The failure can be because of hardware, software or power etc. For
example, if debit transaction discussed above fails after executing operation 2,
the value of A will remain 5000 in the database which is not acceptable by the
bank. To avoid this, Database has two important operations:

Commit: After all instructions of a transaction are successfully executed, the


changes made by transaction are made permanent in the database.
Rollback: If a transaction is not able to execute all operations successfully, all
the changes made by transaction are undone.
==============================================

Properties of a transaction

Atomicity: As a transaction is set of logically related operations,


either all of them should be executed or none.
A debit transaction discussed above should either execute
all three operations or none.If debit transaction fails after
executing operation 1 and 2 then its new value 4000 will not be
updated in the database which leads to inconsistency.
==========================================
Consistency: If operations of debit and credit transactions on same account are
executed concurrently, it may leave database in an inconsistent state.

A=5000RS
A-1000
A=4000
A+500
A=4500
For Example, T1 (debit of Rs. 1000 from A) and T2 (credit of 500 to A) executing
concurrently, the database reaches inconsistent state.
Let us assume Account balance of A is Rs. 5000. T1 reads A(5000) and stores the
value in its local buffer space. Then T2 reads A(5000) and also stores the value in
its local buffer space.
T1 performs A=A-1000 (5000-1000=4000) and 4000 is stored in T1 buffer space. Then
T2 performs A=A+500 (5000+500=5500) and 5500 is stored in T2 buffer space. T1
writes the value from its buffer back to database.
A’s value is updated to 4000 in database and then T2 writes the value from its
buffer back to database. A’s value is updated to 5500 which shows that the effect
of debit transaction is lost and database has become inconsistent.
To maintain consistency of database, we need concurrency control protocols which
will be discussed in next article. The operations of T1 and T2 with their buffers
and database have been shown in Table 1.
https://www.geeksforgeeks.org/concurrency-control-in-dbms/

You might also like