[GENERAL] How to create unique index on multiple columns where the combination doesn't matter? - Mailing list pgsql-general

From Glen Huang
Subject [GENERAL] How to create unique index on multiple columns where the combination doesn't matter?
Date
Msg-id 27CF1813-7E38-4928-8566-A24E7D45BAF2@gmail.com
Whole thread Raw
Responses Re: [GENERAL] How to create unique index on multiple columns wherethe combination doesn't matter?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: [GENERAL] How to create unique index on multiple columns wherethe combination doesn't matter?  (Andreas Kretschmer <akretschmer@spamfence.net>)
Re: [GENERAL] How to create unique index on multiple columns wherethe combination doesn't matter?  (Alban Hertroys <haramrae@gmail.com>)
List pgsql-general
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.


pgsql-general by date:

Previous
From: Alexander Farber
Date:
Subject: Re: [GENERAL] COPY ... FROM stdin WITH FORMAT csv
Next
From: "David G. Johnston"
Date:
Subject: Re: [GENERAL] How to create unique index on multiple columns wherethe combination doesn't matter?