Monday, 15 August 2011

c# - How to handle duplicate data or avoid clashes? -


We are trying to create a resource booking system and users can book in place or book for people in the system. Multiple users can make multiple bookings for the same resource at the same time. For example, users A, B, and C are trying to book Place-A for the following time.

User A => 17/03/2015 10:00 to 12:00 - >> 17/03/2015 14:00 to 15:00 => 18/03/2015 from 10:00 to 12 : 00 => 18/03/2015 14:00 to 15:00

User B => 17/03/2015 11:00 to 12:00 => 18/03/2015 from 10:00 12:00

User C => 17/03/2015 11:30 to 13:30

Resource conflict to avoid double booking for the system at the same time or overlap time It is necessary to handle Only one user can take the resource and the rest of the booking should fail. My question is, what is the right way to handle it? Should we use transaction or table lock before inserting data into the table? We are using Visual Studio 2008 and SQL Server 2008. Many thanks for your advice and we really appreciate it.

There are at least 2 business processes involved in this.

  • Process A:

Show available seats.

  • Two processes:

Book a location.

Since these processes have not been complied with each other, and 2 people can choose the same place-A, the concurrency issue arises.

If your database design assigns the correct specificity barrier:

-LocationID

- The combination of timestamp (like 10 to 12, 15 to 17) < / P>

If unique, then the database will stop duplicates.

The following scenario is also possible, but will be taken care of by the above suggested implementation:

Considering the grid view available for a given theater and the given event can be displayed :

  1. Available resources available (and becomes => 17/03/2015 from 10:00 to 12:00 a.)
  2. User2 displayed seats (and ho => 17/03/2015 from 10:00 to 12:00 a)
  3. User 1 speaks something on the phone
  4. User 2 goes and says that Tabane (17/03/2015 10: 00 location A)
  5. User1 tries the book (17/03/2015 10:00 location A) (as it is available on its screen)
  6. Unique index prevents stage 5 from coming to data.

Anything that needs to be done can be the right choice on the right database design and constraints.

Other more complex approaches are possible if you want, using transaction queues. In this case, the requests are first written in the queue, then a process starts every second, but it is rarely practical or practical in your case.

Really interesting thing is that the list grid for user 1?


No comments:

Post a Comment