Re: Q: inheritance

Поиск
Список
Период
Сортировка
Искать
От
Richard Broersma
Тема
Re: Q: inheritance
Дата
Msg-id
396486430812040933u52d922c4y5607a6fb6ba9be9e@mail.gmail.com
Ответ на
Q: inheritance (Rüdiger Sörensen)
Список
Дерево обсуждения
Re: Resp.: Automatic insert statement generator? Sebastian Tennant <sebyte@smolny.plus.com>
Re: Resp.: Automatic insert statement generator? Raymond O'Donnell <rod@iol.ie>
On Thu, Dec 4, 2008 at 8:40 AM, Rüdiger Sörensen
 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 по дате отправления
От: A. Kretschmer
Дата:
Сообщение: Re: Job scheduling in Postgre
От: Kynn Jones
Дата:
FAQ