Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is meant by the concurrent execution of database transactions in a multiuser system? why concurrency control is needed?

what is meant by the concurrent execution of database transactions in a multiuser system? why concurrency control is needed?

I'm having trouble with this. and what are some informal examples for concurrency control. any help would be greatly appreciated.

like image 373
Stephanie Dente Avatar asked Apr 19 '11 20:04

Stephanie Dente


People also ask

Why there is a need for concurrent execution of transactions?

Concurrent execution reduces the unpredictable delays in running transactions. Moreover, it also reduces the average response time: the average time for a transaction to be completed after it has been submitted.

Why is concurrency control necessary in multi-user databases?

Multi-User databases need to control the order in which data are read and updated by multiple users. Concurrency Control provides a mechanism to ensure that the work of multiple users do not interfere and potentially corrupt the data in the database.

Why do we need concurrency?

It enable to run multiple applications at the same time. It enables that the resources that are unused by one application can be used for other applications. Without concurrency, each application has to be run to completion before the next one can be run. It enables the better performance by the operating system.

What is concurrency control and why does a DBMS need a concurrency control facility?

In a database management system (DBMS), concurrency control manages simultaneous access to a database. It prevents two users from editing the same record at the same time and also serializes transactions for backup and recovery.


2 Answers

Concurrent execution of database transactions in a multi-user system means that any number of users can use the same database at the same time. Concurrency control is needed in order to avoid inconsistencies in the database.

Here is an example of how this scenario can lead to an inconsistency:

Assume we have two users, Alice and Bob, who both have access to the same bank account. Alice wants to deposit $100 and Bob wants to withdraw $200. Assuming there is $500 in the account, here is how the execution might take place if they perform their actions at the same time:

  1. Alice gets initial amount (x = $500)
  2. Bob gets initial amount (x = $500)
  3. Alice deposits $100 (x + 100) = $600
  4. Bob withdraws $200 (x - 200) = $300
  5. Alice saves the new balance ($600)
  6. Bob saves the new balance ($300)

New balance after both actions should be $400. Now the database is in an inconsistent state.

Concurrency control can prevent inconsistencies by providing Alice with a temporary "lock" on the database until she is done with her action.

like image 70
Justin Avatar answered Oct 24 '22 03:10

Justin


Well, it is as simple as this... Say you have a bank, and simultaneously two persons try to withdraw €100 from an account with €100 on it. These are concurrent operations.

You need to make sure that only one of them manage to withdraw 100€. This is concurrency handling.

like image 44
Johan Kotlinski Avatar answered Oct 24 '22 01:10

Johan Kotlinski