Re: problem referencing an attrib which is not unique

From: Richard Huxton <dev(at)archonet(dot)com>
To: Vic Rowan <mightymate(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: problem referencing an attrib which is not unique
Date: 2006-02-07 14:17:15
Message-ID: 43E8ABEB.7000100@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Patrick JACQUOT 2006-02-07 14:27:03 Re: problem referencing an attrib which is not unique
Previous Message Vic Rowan 2006-02-07 13:45:09 problem referencing an attrib which is not unique