blocking a ticket while booking it thru online in website
Joined: Jan 27, 2010
I had an interview sterday. interviewer asked me a question.
A person "A" books a fligth ticket form 7 steps. while he goes to the first step, he got a message saying one seat is available. he has entered from step 1 till 7 giving his credit card details and all. the question is at the same time if another person "B" with high internet speed conn is trying to book the same ticket. that should be avoided. as soon as the person "A" starts the step 1 till he completes all the steps , none of them shud be able to access the ticket. it should be bocked by the person "A".
my answer was locking the transation from step 1to step7 at the database level. is that correct.
Can any one suggest me with the proper answer.
Joined: Apr 26, 2007
Locking the transaction will only give integrity to the process, but not necessarily the integrity to ticket count remaining. You answered it correctly, but I guess we can add a bit more of information to press the result
What I am thinking is like a temporary buffer - The moment someone passes the step1 (I guess thats where the seat availability check is done), decrement the ticket counter by one, and add one ticket to the in-process buffer (the temporary buffer, I mentioned before) - This ensures that the ticket will be available if the user successfully competes the transaction, no matter what the speed of his connection is. If the transaction fails or is aborted for some reason, you need to do the reverse of the initial process (reduce one ticket from in-process, and add one to the available... and so on)