Re: Inheritence and Integrity - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Inheritence and Integrity
Date
Msg-id 20030129121750.N14196-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Inheritence and Integrity  (Neal Lindsay <neal.lindsay@peaofohio.com>)
Responses Re: Inheritence and Integrity
List pgsql-sql
On Wed, 29 Jan 2003, Neal Lindsay wrote:

> I am creating a database that will keep track of several different types
> of 'events'. I am toying with the idea of making a base 'class' table
> for the tables because a lot of the information will be the same (also
> there will probably be times I just need to get the basic information
> about events regardless of their type). My question is: will triggers
> and rules on the parent table fire when I insert data in the child
> tables? Are there any other potential pitfalls?

Currently that won't do what you want because triggers are not inherited
and the constraint is set up so the references constraint ends up being
only on the rows in parenttable.  In addition, the primary key constraint
won't do what you probably want either, although since it's a serial, you
won't be likely to notice.

> P.S. Here is a simplified example of my schema:
>
> CREATE TABLE parenttable (
>     recordid SERIAL PRIMARY KEY,
>     recordname text
> );
>
> CREATE TABLE childtablea (
>     afield int4
> ) INHERITS parenttable;
>
> CREATE TABLE childtableb (
>     bfield text
> ) INHERITS parenttable;
>
> CREATE TABLE extrainfo (
>     extrainfoid SERIAL PRIMARY KEY,
>     record_fkey int4 NOT NULL REFERENCES parenttable(recordid),
>     extrainfotext text
> );



pgsql-sql by date:

Previous
From: Neal Lindsay
Date:
Subject: Inheritence and Integrity
Next
From: Neal Lindsay
Date:
Subject: Re: Inheritence and Integrity