Re: Trying to Understand Table Inheritance

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>, Keary Suska <hierophant(at)pcisys(dot)net>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trying to Understand Table Inheritance
Date: 2006-12-06 23:55:21
Message-ID: 653466.86528.qm@web31801.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- Jeff > 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.

Then if you wanted, you could add one additional layer to for convienence. you can create
multiple updateable views, one view for each of your extenction tables such as mechandise in this
example that are joined back to your primary table.

This way you can handle each relation seperately.

Regards,

Richard Broersma.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Cornelia Boenigk 2006-12-06 23:57:45 Re: VACUUM and transactions in different databases
Previous Message Bill Moran 2006-12-06 23:39:21 Re: VACUUM and transactions in different databases