Having a 2-column uniqueness constraint

Поиск
Список
Период
Сортировка
От VanL
Тема Having a 2-column uniqueness constraint
Дата
Msg-id bfjl0r$prl$1@main.gmane.org
обсуждение исходный текст
Ответы Re: Having a 2-column uniqueness constraint  ("Shridhar Daithankar" <shridhar_daithankar@persistent.co.in>)
Re: Having a 2-column uniqueness constraint  (Patrick Welche <prlw1@newn.cam.ac.uk>)
Список pgsql-general
Hello,

I know that it is possible to have a 2-column primary key, which
enforces uniqueness of the combination of those two columns.  However,
for our schema, we need to have a single column (integer) primary key,
but we still wish to enforce uniqueness across two particular columns.

For example:

id (integer primary key) | domain_name (varchar (255)) | mid (other id)

The id is, as shown, the primary key.  The mid is the primary id of
another table (the management unit), with a foreign key constraint that
keeps the reference correct.

How can I make sure that the there is only one instance of a particular
domain name in each management unit?

Put another way, how can I set a (domain_name, mid) UNIQUE constraint?

Thanks,

VanL


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

Предыдущее
От: Vivek Khera
Дата:
Сообщение: Re: Checkpoint question
Следующее
От: "Shridhar Daithankar"
Дата:
Сообщение: Re: Having a 2-column uniqueness constraint