X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8A8885285B for ; Tue, 7 Jun 2005 12:45:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88519-09 for ; Tue, 7 Jun 2005 15:45:35 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 7C19F5283C for ; Tue, 7 Jun 2005 12:45:34 -0300 (ADT) 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 86C99415C42; Tue, 7 Jun 2005 16:45:22 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 9C7D515ED5; Tue, 7 Jun 2005 16:43:17 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 31830-02; Tue, 7 Jun 2005 16:43:09 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 4804D15EE4; Tue, 7 Jun 2005 16:41:17 +0100 (BST) Message-ID: <42A5C01C.1050007@archonet.com> Date: Tue, 07 Jun 2005 16:41:16 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "M.D.G. Lange" Cc: pgsql-sql@postgresql.org Subject: Re: rule or trigger? References: <42A576E5.1040100@dltmedia.nl> In-Reply-To: <42A576E5.1040100@dltmedia.nl> 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, hits=0.054 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200506/107 X-Sequence-Number: 21708 M.D.G. Lange wrote: > In order for a "dictionary" system I have created the following system: > > tbllanguages > - ID > - name > Primary key ( ID ) > > tbldictionary > - wordid > - languageid > - value > Primary key ( wordid, languageid) > > The idea is to have a word id in several languages, so you only have to > look up the word id and give the language you would like to get the > message in and you'll be presented the translation. > So far so good... only wordid is not unique, making it not suitable to > use it in foreign keys... however I'd like a similar idea: > > tblsystemmessages > - ID > - wordid > - pgsqlerrorcode > Primary key ( ID ) > "Foreign key" wordid references tbldictionary.wordid > > It is not possible to create a constraint Foreign key for "wordid". No > problem there, but I want to be certain that a given wordid exists in > tbldictionary. I'd split the existence of the word from its presence in the language-lookup table. Then you can have a reference to the existence of the "raw word". raw_words - wordid - wordname Of course "wordname" will probably be in one of your target languages anyway, but conceptually doesn't have to be. You can always have triggers on tbldictionary to automatically insert into raw_words if you'd like. -- Richard Huxton Archonet Ltd