Search Postgresql Archives

Enforcing adjacent ranges

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)

CREATE 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?

Thanks,

Ben

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux