Combine a PostgreSQL EXCLUDE range constraint with a UNIQUE constraint -


in postgresql, how combine exclusion constraint on range column unique constraint on other, scalar columns. or put way, how ensure range overlap check done in combination unique check on other columns?

for example, have:

create table reservation (     restaurant_id int,     time_range tsrange ); 

i want make sure each restaurant_id, there no overlapping time_ranges.

i know can create exclusive range constraint this:

create table reservation (     restaurant_id int,     time_range tsrange exclude using gist (time_range &&) ); 

but how make sure time_range check scoped restaurant_id?

create table reservation  (     restaurant_id int,     time_range tsrange,     exclude using gist (restaurant_id =, time_range &&) ); 

note need install extension btree_gist because gist index not have equality operator default:

http://www.postgresql.org/docs/current/static/btree-gist.html


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -