Re: Trying to Understand Table Inheritance

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Re: Trying to Understand Table Inheritance
Дата
Msg-id 1165447682.2048.76.camel@dogma.v10.wvs
обсуждение исходный текст
Ответ на Trying to Understand Table Inheritance  (Keary Suska <hierophant@pcisys.net>)
Ответы Re: Trying to Understand Table Inheritance  (Richard Broersma Jr <rabroersma@yahoo.com>)
Список pgsql-general
On Wed, 2006-12-06 at 13:58 -0700, Keary Suska wrote:
> My thoughts then turned to table inheritance, but I am not sure whether this
> addresses the issue or introduce new problems. My thought was that I could
> have an "order_item" table with the columns/data shared by all line items,
> and then have three tables--merchandise, membership, and subscription--that
> inherit from it.
>

There are two ways to accomplish basically the same thing. I think Erik
already answered your inheritance questions, but it's possible to do
without inheritance as well.

You can create a table called order_item with columns that exist for all
items (the shared columns). Create a table called merchandise with
columns that exist only for merchandise and not other items (without any
of the shared columns).

When you insert new merchandise, put the common values into the
order_item table, and the merchandise-specific attributes into the
merchandise table with a foreign key to the order_item record. When you
want all the items, select from order_item. When you want only the
merchandise, join the order_item and merchandise tables, and of course
the join will eliminate all non-merchandise records. And you can do the
same for memberships and subscriptions.

Hope this helps,
    Jeff Davis


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Update Perrformance with nested loop vs. merge-join
Следующее
От: Cornelia Boenigk
Дата:
Сообщение: VACUUM and transactions in different databases