views:

21

answers:

2

Hi all,

Im about to create a very simple online event reservation application and currently have 3 tables:

User

  • PK_UserID
  • UserName

Event

  • PK_EventID
  • EventName
  • EventDescription
  • EventStartDate
  • EventEndDate
  • SeatsAvailable

BookedEvents

  • ID
  • FK_UserID
  • FK_EventID

Do you have any experience of how to handle SeatsAvailable? I mean if SeatsAvailable is set to 5 and there are 5 users online and want to book event. And some user has started to fill out the form then changed his mind. Then seats in database can just leak. I was thinking about sessions - like to limit every user to 5 minutes to complete the booking but i dont really know if its good idea. Do you have any suggestions?

A: 

I would use your way as well, but I would reset the timeout everytime the booking is progressed (ie. new page). I know from experience you sometimes have to look something up or similar, and I really hate pages timing out in that case. You should be fine with a timeout.

Femaref
+1  A: 

I dont really see your problem.

SeatsAvailable would be the total allowed seats, and the number of booked users would be the sum of the rows on BookedEvents.

in your procedure to enter a user to BookedEvents you would read the count of BookedEvents and SeatsAvailable in a transaction, if the event is full then the users gets a message saying the they are too late

am i missing something?

CrapHands