Re: [SQL] inheritance and foreign key

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Kancha (dot)" <kancha2np(at)yahoo(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] inheritance and foreign key
Date: 2002-02-19 16:53:54
Message-ID: 20020219085215.S86265-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql


On Tue, 19 Feb 2002, Kancha . wrote:

> I'm a postgresql newbie.
>
> It seems that primary key is not inherited by tables.
> My situtation is as follows
>
> I've a parent table and child tables with inherit from
> parent table. Parent table consists of pid (defualt
> value of pid is from sequence) that is primary key.
> Now all child tables inherits this attribute pid.
>
> I've another table from where i reference this pid as:
>
> pid integer references parent (pid)
>
> the table creation is successful, but when i try to
> insert data into this table that refereces parent
> table i get error - something like the referenced
> column doesn't exist.

Foreign key references currently go only to the table
that explicitly named, not to any children tables so
it won't see values of pid in the children. There's
a few workaround solutions for cases like yours that have
been sent to the mailing lists before, you may be able
to find them on the archives.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Wood 2002-02-19 16:54:16 Re: creating tables from a disk file
Previous Message Percy 2002-02-19 16:49:51 number of connections to postmaster

Browse pgsql-sql by date

  From Date Subject
Next Message Marius Andreiana 2002-02-19 17:14:44 Re: Postgres vs. Mysql
Previous Message Rajesh Kumar Mallah 2002-02-19 16:48:45 Re: SQL For smarties