Need help writing exclusion constraint

From: Matthew Wilson <matt(at)tplus1(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Need help writing exclusion constraint
Date: 2011-01-15 19:17:48
Message-ID: igsrss$3a5$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table like this:

create table event(

destination_id integer not null references destination
(destination_id),

starts timestamp,
ends timestamp
);

I want to make sure that no two rows **with the same destination_id**
overlap in time.

I'm not sure how to write this exclusion constraint. I know how to make
the constraint to prevent any two rows from overlapping, but I want to
allow rows to overlap as long as they don't have the same
destination_id.

Thanks in advance.

Matt

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Godoy 2011-01-15 19:32:38 Re: How to generate unique invoice numbers foreach day
Previous Message Andrus Moor 2011-01-15 19:09:06 Re: How to generate unique invoice numbers foreach day