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 07ACCD1B211 for ; Fri, 23 Jul 2004 03:08:51 -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 47680-04 for ; Fri, 23 Jul 2004 06:08:50 +0000 (GMT) Received: from rock.spider.ru (rock.spider.ru [62.183.34.226]) by svr1.postgresql.org (Postfix) with ESMTP id ADFE8D1B18A for ; Fri, 23 Jul 2004 03:08:42 -0300 (ADT) Received: from rock (localhost [127.0.0.1]) by rock (Postfix) with SMTP id A35E12742A for ; Fri, 23 Jul 2004 10:08:46 +0400 (MSD) Received: from sad.localnet.ru (sad.localnet.ru [10.0.0.72]) by rock.spider.ru (Postfix) with ESMTP id E105427427 for ; Fri, 23 Jul 2004 10:08:45 +0400 (MSD) Content-Type: text/plain; charset="iso-8859-1" From: sad Organization: IT To: pgsql-sql@postgresql.org Subject: Re: surrogate key or not? Date: Fri, 23 Jul 2004 09:16:50 +0400 User-Agent: KMail/1.4.3 References: <1090325769.3241.27.camel@dicaprio.akademie1.de> <200407211025.33615.josh@agliodbs.com> <20040722142040.H3720@hermes.hilbert.loc> In-Reply-To: <20040722142040.H3720@hermes.hilbert.loc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200407230916.50436.sad@bankir.ru> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/192 X-Sequence-Number: 18444 I want to add some notes > create table diagnosis ( > pk serial primary key, > fk_patient integer > not null > references patient(pk) > on update cascade > on delete cascade, > narrative text > not null, > unique(fk_patient, narrative) > ); 1) a sequence generates INT8 values (in general) and you have INT4 field to= =20 refer to a serial field. 2) narrative TEXT is very bad to check uniquness becauce it is non-formal= =20 human-generated native-language text. so it contains missprints, it may be= =20 rephrased many ways with the same meaning. 3) afaik a diagnosis doesn't belong to a patient, it belongs to a History, and History is marked with a date and status and= =20 belongs to a patient. do not treat my words as The Truth.=20