Re: many columns with references to one table

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Andreas Fromm <Andreas(dot)Fromm(at)physik(dot)uni-erlangen(dot)de>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: many columns with references to one table
Date: 2003-08-26 15:35:31
Message-ID: 20030826083245.C30963-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Tue, 26 Aug 2003, Andreas Fromm wrote:

> Hi,
>
> What is the problem with the following table declaration?
>
> CREATE TABLE persons (
> id SERIAL PRIMARY KEY,
> name TEXT NOT NULL,
> bdate DATE,
> address INTEGER REFERENCES addresses,
> phonepriv INTEGER REFERENCES phones,
> phoneday INTEGER REFERENCES phones,
> phonemobil INTEGER REFERENCES phones,
> email INTEGER REFERENCES emails,
> mate INTEGER REFERENCES persons,
> updated DATE NOT NULL
> );
>
> My problem is that the references to the phones table do not get
> restricted, i.e. I can insert any value in the phone*-fields, while the
> references to the other tables are restricted to values that allready
> exists. The table declaration of phones should be all right, it has a
> primary key defined like every other tables I have. Is there a
> restriciton that no more then 1 column may reference an other table?

Not as far as I know (and I've done multiple references to the same table
in the pash) with the exception that versions before either 7.3 or 7.2 are
going to have problems with referential actions other than NO ACTION in
such cases.

Can you make a complete standalone example?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-08-26 15:42:48 Re: Index usage
Previous Message Tom Lane 2003-08-26 15:34:36 Re: 7.4b1 vs 7.3.4 performance