开发者

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.


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.


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.


My english is not so good but I am trying my best to answer the term mentioned.

In my view, the action will be too fast that it seems doing the work by the number of users at the same time. Doing the work at the same time means doing the work parallelly but this doesn't happen in the case of concurrent.

Concurrency is when two tasks can start, run, and complete in overlapping time periods. It doesn't necessarily mean they'll ever both be running at the same instant.

Eg. multitasking on a single-core machine.


Concurrent execution of database transactions in a multi-user system is where 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. Examples Assume that there are two administrators oliver and gorge who have access to the same users’ database record in an organization. Oliver is trying to update one of the records of a particular user at the same time Ross is trying to update a record of the same user. If there are no proper ways of dealing with the simultaneous access of this data, possibly the final result of the updated data of that user might be inaccurate

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜