Inheritance question

From: "Raymond C(dot) Rodgers" <pgsql(at)bbnk(dot)dhs(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Inheritance question
Date: 2007-05-24 23:49:24
Message-ID: 46562484.50405@bbnk.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

First, I want to confess that I am not an SQL expert or even remotely
close. :-)
Second, I believe I pretty much know the answer to my question, but I
would like to have some confirmation if you fine people don't mind.

My situation is this: I have a PHP script that some what dynamically
generates two or more tables (but for the sake of this email lets stick
with two), and a view to display the results of those tables. The tables
might be defined like this:

Table A
======
id bigint not null (Primary Key)
b0 int not null
b1 int not null
b2 int not null

Table B
======
id bigint not null (Primary Key)
b0 int not null
b1 int not null
b2 int not null
b3 int not null

And the view ultimately maps those tables in combination with Table C
which contains a serial column that the id in Tables A & B use. The view
might have been created like this:

create view View1 as select c.id, a.b0 as r0, a.b1 as r1, a.b2 as r2,
b.b0 as r3, b.b1 as r4, b.b2 as r5, b.b3 as r6 from TableC c left join
TableA a on c.id = a.id left join TableB b on c.id = b.id

This results in a virtual table/view that contains all of the columns
from tables A & B, in addition to another column from table C. That's
fine for most of my purposes.

I only recently learned about the inheritance features, and I was hoping
that I could find a way to implement a table that is the child of tables
A & B that would allow me to map the columns as I desire rather than
automatically merging them. Based on the documentation and my own
testing, I would have to say that this isn't possible in 8.1 (which I
currently use) or 8.2 (which I'll be moving to soon).

The question, and point, is this: Is there an alternate way of
accomplishing read and write functionality similar to what inheritance
offers but allowing me to map the columns as I desire? The read only
view is nice, but it would save me a lot of work if I could take
advantage of inheritance in this way.

Thanks for your time and patience!
Raymond

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo De León 2007-05-25 00:05:20 Re: Limiting number of rows returned at a time in select query
Previous Message Raymond C. Rodgers 2007-05-24 23:44:53 Inheritance question