Enforcing adjacent ranges

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Enforcing adjacent ranges

Ben Leslie-2
I'm wondering if there is anyway to enforce that ranges in a table be adjacent in perhaps a similar way to enforcing that they are non-overlapping.

Consider a (very simplified table)

  thing_id int,
  period tsrange,
  EXCLUDE USING gist (thing_id WITH =, period WITH &&),
  CHECK (lower_inc(period) and not upper_inc(period))

This should (I believe) enforce that all periods for a given thing are non-overlapping, and that each is lower-inclusive, upper-exclusive ranges.

I'd also like to enforce that all ranges for a given 'thing' are adjacent. 

Is that possible?


Previous Thread Next Thread