serial as FK ? - Mailing list pgsql-hackers

From Oleg Bartunov
Subject serial as FK ?
Date
Msg-id Pine.GSO.4.62.0502281221300.18315@ra.sai.msu.su
Whole thread Raw
Responses Re: serial as FK ?
List pgsql-hackers
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
    Regards,        Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


pgsql-hackers by date:

Previous
From: Richard Huxton
Date:
Subject: Re: serial as FK ?
Next
From: Evgen Potemkin
Date:
Subject: Re: SQL99 Hierarchical queries