Gracefully processing reservations at the same time and day

Suppose I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm

If a customer makes a booking and they are on the same day and time as the other booking, how can I gracefully handle this business problem? Also, what if two orders are running at the same time? This is a concurrency issue like with multithreading.

I am working with Sqlite, C # and ASP.NET for this project.

thank

+1


source to share


1 answer


This requires transactions. The booking code should BEGIN the transaction, confirm that the time is available with SELECT and if available, INSERT or UPDATE the database to reserve, finally COMMITing the transaction.



If the time is not available, either DO NOT INSERT or UPDATE the database to back up, or ROLLBACK the transaction.

+4


source







All Articles