How to use a cross column exclude constraint

Поиск
Список
Период
Сортировка
От awolchute@tutanota.com
Тема How to use a cross column exclude constraint
Дата
Msg-id NA0w1JZ--J-2@tutanota.com
обсуждение исходный текст
Ответы Re: How to use a cross column exclude constraint  (chidamparam muthusamy <mchidamparam@gmail.com>)
Список pgsql-novice

Hi All,

Schema:
CREATE TABLE record (        id uuid primary key default ...,    ...
);

CREATE TABLE record_pointer (    id uuid primary key default ...,    record_a_id uuid not null references record (id),    record_b_id uuid not null references record (id),    ...
);

I am trying to create an exclude constraint to make both record_a_id and record_b_id unique table wide, so that each row from "record" can ever be referenced once in "record_pointers". 

Eg. if I add a record_pointer row that has "this-is-random-uuid" as record_a_id, the value "this-is-random-uuid" can never be in record_a_id or record_b_id in any other row.


Thank you in advance!


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

Предыдущее
От: Steve T
Дата:
Сообщение: Re: database encoding migration from a pg_dumpall set
Следующее
От: chidamparam muthusamy
Дата:
Сообщение: Re: How to use a cross column exclude constraint