Challenging Task: How to prevent double bookings

Challenging Task: How to prevent double bookings

Good morning  zoho crew!

My new task is how to prevent double bookings.

Stateless form Guest_Reserve

form Test_Reserve holds the table

 
fields
date time  Zoho date/time start
datetime  Zoho date/time end
number Number_of_Riders
number Current_Seats_Available
picklist Status (Reserved, Waiting, Available)
is there a way for zoho to check for times that are booked ?

maybe something like

count  Zoho date/time start between Zoho date/time end
if input.Number_of_Riders is more than Number_of_Riders
mark reserved
Cancel Submit

or

fetch record rec. Test Reserve Zoho date/time start =input Zoho date/time start
                          Zoho date/time end=input Zoho date/time end

if Current available seats for any of these records matching the customers entry is 0
Cancel Submit
"Alert" "these times are already booked"                            


example for writing in script? Any ideas?