This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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.
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)