---
title: "Comment by Ahmed Elbashier on \"A Booking API That Cannot Promise the Same Slot Twice\" | Hashnode"
description: "Putting the invariant in an exclusion constraint is the right call. For the half-open interval to work you want tstzrange(starts_at, ends_at, '[)') in the const"
url: "https://hashnode.com/posts/a-booking-api-that-cannot-promise-the-same-slot-twice/6b08bdd61227f2d761c170d3/comment/6b0d5a74a6eeffc420a73ec1"
---

[Discussion](https://hashnode.com/posts/a-booking-api-that-cannot-promise-the-same-slot-twice/6b08bdd61227f2d761c170d3)

Comment [A Booking API That Cannot Promise the Same Slot Twice](https://hashnode.com/posts/a-booking-api-that-cannot-promise-the-same-slot-twice/6b08bdd61227f2d761c170d3)

[Ahmed Elbashier](https://hashnode.com/@ahmedelbashier)

[1d ago](https://hashnode.com/posts/a-booking-api-that-cannot-promise-the-same-slot-twice/6b08bdd61227f2d761c170d3/comment/6b0d5a74a6eeffc420a73ec1)

Putting the invariant in an exclusion constraint is the right call. For the half-open interval to work you want tstzrange(starts\_at, ends\_at, '\[)') in the constraint. How do you handle temporary holds that expire? I'd expect a partial constraint (WHERE state IN ('held','confirmed')) plus a sweeper, but I'm curious whether you'd rather let the hold lapse by timestamp.
