Question: unique on multiple columns

Поиск
Список
Период
Сортировка
От roverr
Тема Question: unique on multiple columns
Дата
Msg-id 1044445595.13526.15.camel@junkyard
обсуждение исходный текст
Ответы Re: Question: unique on multiple columns  (Arjen van der Meijden <acm@tweakers.net>)
Re: Question: unique on multiple columns  (will trillich <will@serensoft.com>)
Список pgsql-general
I'm running postgresql 7.2.1.
Is there a way to specify a constraint such that the combination
of two columns in a table is unique?

I have a table as follows:
col 1: id, type serial, primary key
col 2: host_id, type integer, foreign key to hosts table
col 3: data_time, type timestamp
col 4 - 9 data that is unique to col 2 and 3

I wish to have a constraint such that the combination
of the host_id entry in col 2 and each data_time entry
in col 3 must be unique.
My thoughts are to calculate a new column based on
col 2 and 3 and force that to be unique.  Is this
the correct approach or is my table layout hopelessly
flawed?

Thanks in advance,
Gary


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

Предыдущее
От: "Vilson farias"
Дата:
Сообщение: Temporary and permanent tables with same name
Следующее
От: RobertD.Stewart@mail.state.ky.us
Дата:
Сообщение: Functions and triggers can anyone help