Re: Inheritance and column references problem

From: "Vidyasagara Guntaka" <vguntaka(at)candera(dot)com>
To: "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Inheritance and column references problem
Date: 2004-02-27 18:59:16
Message-ID: 5F90B589E007484AA3C305D4AE984C750ED3B9@mail2.confluencenetworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Will the current behavior change in the upcoming releases ? Currently I'm
investigating if we can replace a proprietary database with postgresql. For
our object model inheriting the primary key and foreign key constraints is
essential.

Also, Can you please point to some resources which describe ways to circumvent
the problem.

Thank you very much in advance.

Sagar.

-----Original Message-----
From: Stephan Szabo [mailto:sszabo(at)megazone(dot)bigpanda(dot)com]
Sent: Tuesday, February 24, 2004 4:38 PM
To: Scott Goodwin
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Inheritance and column references problem

> Is this a bug, or a feature? It seems I can't make a column reference
> work directly with the table that gets inherited by the others. Neither
> can I make a column reference work with a table that *inherits* the
> toinherit table. If I can't get this to work, I'll have to revert back
> to not using inheritance at all.

All of primary key, unique and foreign key constraints don't currently
meaningfully inherit. For the foreign key case the reference goes only
to the directly named table so rows in the subtables are not considered
for purposes of validating the constraint. In addition, in a structure
where you have a primary key inherited, the child tables do not get the
constraint for uniqueness although that can be added by explicitly putting
the constraint on, however that won't prevent duplicates between the child
and parent nor between children. There are some marginally complicated
workarounds using a separate table that have been discussed on the lists
before and should be available in the archives.

I think I should build a macro for the above. ;)

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2004-02-27 19:09:37 Re: PostgreSQL in Cluster
Previous Message terry 2004-02-27 18:50:29 Re: field must appear in the GROUP BY clause or be used