Re: [HACKERS] serial as FK ?

2005-02-28 Thread Oleg Bartunov
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

Re: [HACKERS] serial as FK ?

2005-02-28 Thread Richard Huxton
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:

[HACKERS] serial as FK ?

2005-02-28 Thread Oleg Bartunov
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

Re: [HACKERS] serial as FK ?

2005-02-28 Thread Stephan Szabo
On Mon, 28 Feb 2005, Oleg Bartunov wrote: what's wrong to use SERIAL as FK without explicit PRIMARY KEY or UNIQUE ? Serial isn't enough to guarantee uniqueness as required by foreign keys. ---(end of broadcast)--- TIP 8: explain analyze is your

Re: [HACKERS] serial as FK ?

2005-02-28 Thread Oleg Bartunov
On Mon, 28 Feb 2005, Stephan Szabo wrote: On Mon, 28 Feb 2005, Oleg Bartunov wrote: what's wrong to use SERIAL as FK without explicit PRIMARY KEY or UNIQUE ? Serial isn't enough to guarantee uniqueness as required by foreign keys. you're certainly right ! Regards, Oleg