Re: [GENERAL] How to create unique index on multiple columns wherethe combination doesn't matter?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [GENERAL] How to create unique index on multiple columns wherethe combination doesn't matter?
Дата
Msg-id CAKFQuwa9ZER4yPfXgHAoX18O_qTj07ZVKvkAPYVeajYyPzTd5w@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] How to create unique index on multiple columns where the combination doesn't matter?  (Glen Huang <hey.hgl@gmail.com>)
Ответы Re: [GENERAL] How to create unique index on multiple columns wherethe combination doesn't matter?  (Glen Huang <hey.hgl@gmail.com>)
Список pgsql-general
On Wed, Mar 22, 2017 at 9:54 AM, Glen Huang <hey.hgl@gmail.com> wrote:
Hello,

If I have a table like

CREATE TABLE relationship (
  obj1 INTEGER NOT NULL REFERENCES object,
  obj2 INTEGER NOT NULL REFERENCES object,
  obj3 INTEGER NOT NULL REFERENCES object,
  ...
)

And I want to constrain that if 1,2,3 is already in the table, rows like 1,3,2 or 2,1,3 shouldn't be allowed.

Is there a general solution to this problem?

Sorry if the question is too basic, but I couldn't find the answer in the doc, at least not in the chapter on unique index.

The most direct option to consider is a exclusion constraint.


David J.

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

Предыдущее
От: Glen Huang
Дата:
Сообщение: [GENERAL] How to create unique index on multiple columns where the combination doesn't matter?
Следующее
От: Rakesh Kumar
Дата:
Сообщение: Re: [GENERAL] Incremental / Level -1 backup in PG