pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Vic Rowan <mightymate@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: problem referencing an attrib which is not unique
Date: Tue, 07 Feb 2006 14:17:15 +0000
Message-ID: <43E8ABEB.7000100@archonet.com> (raw)
In-Reply-To: <450bdf80602070545v56252a49g8dfe0d0d04ae9065@mail.gmail.com>
References: <450bdf80602070531w78b687bdj15e640945b15b49@mail.gmail.com>
	<450bdf80602070545v56252a49g8dfe0d0d04ae9065@mail.gmail.com>

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



view thread (4+ messages)  latest in thread

Message-ID: <43E8ABEB.7000100@archonet.com>
Permalink:  ../43E8ABEB.7000100@archonet.com/
Also on:    postgresql.org/message-id/43E8ABEB.7000100@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, mightymate@gmail.com
  Subject: Re: problem referencing an attrib which is not unique
  In-Reply-To: <43E8ABEB.7000100@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox