Click here to Skip to main content
15,891,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey I'm currently working on a cinema practice project using WCF, and I've reach a milestone where multi-threading seems to be a great option to actually have benefits from the extra core in case, lets say hundred of people was to order a reservation to a movie at once. my current structure looks something like this: Server <--> Business logic <--> DatabaseControler <--> Database

The "Business Logic" is there to check payment, if all requested seats are availble etc. but I also believe it should be the one to handle when what request should be executed, and since writing 100 reservations into a database may end in chaos and seats taken multiple times this would be a huge problem.

So can anyone point me in the right direction of how to handle the Concurrency this will give in a efficient way?

Thanks - Jackie
Posted

In a scenario like this, let the database engine worry about concurrency. The sessions in the business logic are unrelated and don't need to know about each other. It would only slow you down. Simply make sure you have some temporary reservation for customers that are just about to pay (which isn't what's put into their shopping cart). It will keep their seats available when they are in the process of paying. After a few minutes they should be released for sale again if the payment was not successful completed. But the actual concurrency control is done by database transactions.

Good luck!
 
Share this answer
 
Comments
Jackie00100 7-Nov-13 12:01pm    
Ah, I see I'm no near an database expert, I barely knew how joins worked into very recently, but if what you're saying does apply to SQL Server as well, I guess I can just make a check on whether a reservation is matching an other one before writing it to the database?
E.F. Nijboer 7-Nov-13 12:32pm    
It surely applies to SQL Server and actually every relational database system. Without transactions and atomic operations it is impossible to guarantee data integrity. Not that you would need to be an expert, but make sure look into what it all has to offer. Work smart, not hard ;-)
Jackie00100 7-Nov-13 13:51pm    
Understood just for the sake of it could you maybe give some search word to get an idea how to work with this unique, so it is impossible to add 2 equal resevations? - Sorry for keep going, as say never worked with SQL in such advance manner.
The buzzword is ACID!

Here some links to check out. This first is just a nice short story example:
http://michaeljswart.com/2011/07/acid-properties-by-example-and-counterexample-part-one-atomic/[^]

Check out this link for more in depth information. Also check out the left tree with lots more information about transactions and all. The link is just a start start place but you can really eat your heart out.
http://msdn.microsoft.com/en-us/library/aa480356.aspx[^]

Good luck!
 
Share this answer
 
Comments
Jackie00100 7-Nov-13 14:46pm    
Thanks a lot! :D
Sergey Alexandrovich Kryukov 7-Nov-13 16:04pm    
I think both answers are good, voted 5 for both.
—SA
E.F. Nijboer 8-Nov-13 4:11am    
Thanks! :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900