Re: Need help writing exclusion constraint

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: Need help writing exclusion constraint
Дата
Msg-id 20110116135944.GA9617@tux
обсуждение исходный текст
Ответ на Need help writing exclusion constraint  (Matthew Wilson <matt@tplus1.com>)
Список pgsql-general
Matthew Wilson <matt@tplus1.com> wrote:

> 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.

If I where you, i would use the temporal data typ ;-)

It's a new extension for PostgreSQL, see here:
http://temporal.projects.postgresql.org/reference.html,
http://thoughts.j-davis.com/2010/09/25/exclusion-constraints-are-generalized-sql-unique/
http://www.slideshare.net/pgconf/not-just-unique-exclusion-constraints


Regards, Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

В списке pgsql-general по дате отправления:

Предыдущее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: Why can't I change a password
Следующее
От: Вячеслав Блинников
Дата:
Сообщение: libpq: binary data vs textual