Booking systems have an inherent problem: race conditioning.
A naive approach of fixing it is checking availability before inserting a booking, but it still introduces a race condition where multiple requests can pass validation simultaneously.
This is why we need a DB constraint solution, using a UNIQUE constraint on time_slot_id in the bookings table.
Here is my project for proof: https://kerochan.lol/blog/pern.html

Top comments (0)