I am creating a Hotel Booking System for the Android application.

I was thinking about how to implement a safe way to insert a booking into my database. The request will be sent from the app to the MySQL database (which is hosted on a web server) via my web service.

When I create a booking I insert the: CustomerID, HotelID, RoomID (via a nested select statement to find an available room), checkInDate and checkOutDate.

However, how can I ensure that two different people won't book the same/last room if they both hit 'book now' at roughly the same time. I thought about using `Synchornised`for the java method but will that make any difference if a range of different users on different mobiles try to make a booking?