Skip site navigation (1) Skip section navigation (2)

Re: surrogate key or not?

From: sad <sad(at)bankir(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: surrogate key or not?
Date: 2004-07-23 05:16:50
Message-ID: 200407230916.50436.sad@bankir.ru (view raw or flat)
Thread:
Lists: pgsql-sql
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 
refer to a serial field.

2) narrative TEXT is very bad to check uniquness becauce it is non-formal 
human-generated native-language text. so it contains missprints, it may be 
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 
belongs to a patient.

do not treat my words as The Truth. 



In response to

pgsql-sql by date

Next:From: Karsten HilbertDate: 2004-07-23 06:57:21
Subject: Re: surrogate key or not?
Previous:From: Chris CoxDate: 2004-07-22 23:46:27
Subject: Re: LIKE on index not working

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group