Re: Q: inheritance - Mailing list pgsql-general

From Richard Broersma
Subject Re: Q: inheritance
Date
Msg-id 396486430812040933u52d922c4y5607a6fb6ba9be9e@mail.gmail.com
Whole thread Raw
In response to Q: inheritance  (Rüdiger Sörensen <soerense@mpch-mainz.mpg.de>)
Responses Automatic insert statement generator?
List pgsql-general
On Thu, Dec 4, 2008 at 8:40 AM, Rüdiger Sörensen
<soerense@mpch-mainz.mpg.de> wrote:

> insert or update in table "t3" violates foreign key constraint "t3_t1_fkey"
> DETAIL: key(t1)=(1) is not present in table "t1"

> select * from t2;
>  id | num
> ----+-----
>  1 |   1

> can anyone explain this behaviour?
Yes,  PostgreSQL table inheritance is really just Horizontal Table
partitioning with a nifty feature that makes the upper node table
behave more like hierarchical UNION ALL views when SELECTed rather
than actual tables.  So in your case, the record you added to t2
doesn't really exits in t1 so referential integrity throws an error in
t3.

> My database setup relies on inherited
> tables that share a primary key.

In this case, I would recommend you use a vertically partitioned table
design that simulates what you are trying to achieve.  I recently
developed a presentation on this subject if you are interested:

http://wiki.postgresql.org/images/9/91/Pguswest2008hnd.pdf

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Job scheduling in Postgre
Next
From: "Kynn Jones"
Date:
Subject: Re: How to echo statements in sourced file?