Combine a PostgreSQL EXCLUDE range constraint with a UNIQUE constraint
问题 In PostgreSQL, how do you combine an exclusion constraint on a range column with a unique constraint on other, scalar columns. Or to put it another way, how do I ensure that the range overlap check is only done in combination with a unique check on some other columns? For example, say I have: CREATE TABLE reservation ( restaurant_id int, time_range tsrange ); I want to make sure that for each restaurant_id , there are no overlapping time_range s. I know that I can create an exclusive range