Check for already selected time intervals.

i want to check wether the user is selecting a slot already selected by another user that is stored in database.
if yes then the user should not be allowed to book an appointment .
also the time intervals should not overlap.