Re: problem referencing an attrib which is not unique

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: problem referencing an attrib which is not unique
Дата
Msg-id 43E8ABEB.7000100@archonet.com
обсуждение исходный текст
Ответ на problem referencing an attrib which is not unique  (Vic Rowan <mightymate@gmail.com>)
Список pgsql-sql
Vic Rowan wrote:
> CREATE TABLE event_msg (
>   event_id varchar(30) NOT NULL,
>   language char(2) NOT NULL,
>   predefined_msg varchar(250) NOT NULL,
>   PRIMARY KEY (event_id, language)
> );
> 
> CREATE TABLE logs (
>   id int NOT NULL,
>   event_id varchar(30) REFERENCES event_msg (event_id) NOT NULL,
>   placeholder_values varchar(250),
>   priority varchar(20) NOT NULL,
>   timestamp Date NOT NULL,
>   primary key (id)
> );
> 
> 
> The problem I am facing is the event_id from logs is not able to reference
> event_id from event_msg as its not unique.

The problem is with your event_msg table. You have two concepts - 
"event" and "event_msg_localised" but only one table.

The logs table should reference "event" (which has one row for each 
event and a unique event_id). The "event_msg_localised" table also 
references "event".

The event table might only contain the event_id primary-key, but I'd 
probably put a description in their for my own use (perhaps saying what 
values to expect).

HTH
--   Richard Huxton  Archonet Ltd


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

Предыдущее
От: Vic Rowan
Дата:
Сообщение: problem referencing an attrib which is not unique
Следующее
От: Patrick JACQUOT
Дата:
Сообщение: Re: problem referencing an attrib which is not unique