X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7F9AB9DC810 for ; Tue, 7 Feb 2006 10:17:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62544-05 for ; Tue, 7 Feb 2006 10:17:22 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id D78009DC803 for ; Tue, 7 Feb 2006 10:17:12 -0400 (AST) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id A16DD40DF71; Tue, 7 Feb 2006 14:17:16 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 75A9F15EA4; Tue, 7 Feb 2006 14:17:16 +0000 (GMT) Message-ID: <43E8ABEB.7000100@archonet.com> Date: Tue, 07 Feb 2006 14:17:15 +0000 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: Vic Rowan Cc: pgsql-sql@postgresql.org Subject: Re: problem referencing an attrib which is not unique References: <450bdf80602070531w78b687bdj15e640945b15b49@mail.gmail.com> <450bdf80602070545v56252a49g8dfe0d0d04ae9065@mail.gmail.com> In-Reply-To: <450bdf80602070545v56252a49g8dfe0d0d04ae9065@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.116 required=5 tests=[AWL=0.116] X-Spam-Score: 0.116 X-Spam-Level: X-Archive-Number: 200602/60 X-Sequence-Number: 24070 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