Re: Q: inheritance

From: "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>
To: Rüdiger Sörensen <soerense(at)mpch-mainz(dot)mpg(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Q: inheritance
Date: 2008-12-04 17:33:42
Message-ID: 396486430812040933u52d922c4y5607a6fb6ba9be9e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Dec 4, 2008 at 8:40 AM, Rüdiger Sörensen
<soerense(at)mpch-mainz(dot)mpg(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kynn Jones 2008-12-04 17:53:06 Re: How to echo statements in sourced file?
Previous Message A. Kretschmer 2008-12-04 17:31:06 Re: Job scheduling in Postgre