Re: serial as FK ?

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: serial as FK ?
Date: 2005-02-28 14:17:07
Message-ID: Pine.GSO.4.62.0502281703590.18315@ra.sai.msu.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 28 Feb 2005, Richard Huxton wrote:

> Oleg Bartunov wrote:
>> Hi there,
>>
>> what's wrong to use SERIAL as FK without explicit PRIMARY KEY or UNIQUE ?
>>
>> qq=# create table t1( id serial);
>> NOTICE: CREATE TABLE will create implicit sequence "t1_id_seq" for
>> "serial" column "t1.id"
>> CREATE TABLE
>> qq=# create table t2( id2 int4 references t1(id));
>> ERROR: there is no unique constraint matching given keys for referenced
>> table "t1"
>>
>> btw, Richard, I noticed this problem when looked into your example database
>> http://www.archonet.com/pgdocs/chap-exdb.html#EXAMPLE-TABLES
>
> Ah - IIRC there *was* nothing wrong with it when those notes were written
> (and I need to update them, clearly). Back then SERIAL implied UNIQUE too,
> but that was changed (in 7.3 I believe).

There are also some problems in examples. I think your notes are rather
useful.

>
>

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-02-28 14:17:20 Re: snprintf causes regression tests to fail
Previous Message Nicolai Tufar 2005-02-28 13:27:14 Re: snprintf causes regression tests to fail