tags:

views:

115

answers:

2

Hi,

Lets imagine 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 it is in the same day and time as another booking, how can I gracefully handle this business problem? Furthermore, what if two bookings are made at the same time? This is a concurrency issue like with multithreading.

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

Thanks

+4  A: 

This is what transactions are for. Your booking code should BEGIN a transaction, confirm that the time is available using SELECT, and if it is available, INSERT or UPDATE the database to make the reservation, finally COMMITing the transaction.

If the time is not available, either don't INSERT or UPDATE the database to make the reservation, or ROLLBACK the transaction.

Doug Currie
A: 

Thanks for that!

dotnetdev