Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asynchronous SQL Operations

I've got a problem I'm not sure how best to solve.

I have an application which updates a database in response to ad hoc requests. One request in particular is quite common. The request is an update that by itself is quite simple, but has some complex preconditions.

  • For this request the business layer first requests a set of data from the data layer.
  • The business logic layer evaluated the data from the database and parameters from the request, from this the action to be performed is determined, and the request's response message(s) are created.
  • The business layer now executes the actual update command that is the purpose of the request.

This last step is the problem, this command is dependent on the state of the database, which might have changed since the business logic ran. Locking down the data read in this operation across several round-trips to the database doesn't seem like a good idea either. Is there a 'best-practice' way to accomplish something like this? Thanks!

like image 268
Paul Avatar asked Mar 29 '10 13:03

Paul


1 Answers

In simple terms when you execute the update command you are concerned that the database may have changed?

Then call stored procedures that are written defensively and will only update if the data is in an acceptable state when they are called (by checking the foreign key references, data integrity etc.).

Let me know if I can help in mocking up some aspect of this.

like image 108
amelvin Avatar answered Sep 21 '22 03:09

amelvin