database concepts

Advanced SQL : concurrency

Concurrency Control

1. In each of the situations below, the users are accessing the same data at the same time. Which of the situations could give rise to concurrency problems?

Situation Yes No
3 users executing SELECT statements
2 users executing SELECT statements
1 user executing an INSERT statement
1 user executing a SELECT statement
1 user executing an INSERT statement
1 user executing a DELETE statement
2 users executing SELECT statements
1 user executing an UPDATE statement
3 users executing UPDATE statements

Showme

Situation Yes No
3 users executing SELECT statements   no
2 users executing SELECT statements
1 user executing an INSERT statement
yes  
1 user executing a SELECT statement
1 user executing an INSERT statement
1 user executing a DELETE statement
yes  
2 users executing SELECT statements
1 user executing an UPDATE statement
yes  
3 users executing UPDATE statements yes  

2. Why do these situations give rise to possible concurrency problems?

Showme

As soon as one user wants to change the data (with an INSERT, UPDATE or DELETE statement) then possible concurrency problems can occur.

The first situation, the 3 SELECT statements, is the only one where only read access is wanted by the users. Multiple readers (without a writer) will never have concurrency issues. As soon as there is one or more writers then concurrency issues occur.