Re: inserting to a multi-table view - Mailing list pgsql-general

From Michael Shulman
Subject Re: inserting to a multi-table view
Date
Msg-id c3f821000806162032t477acfdeqe907340ec70c2bf1@mail.gmail.com
Whole thread Raw
In response to Re: inserting to a multi-table view  (Craig Ringer <craig@postnewspapers.com.au>)
Responses Re: inserting to a multi-table view  ("Richard Broersma" <richard.broersma@gmail.com>)
List pgsql-general
On Mon, Jun 16, 2008 at 10:27 PM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
>> I want to be able to do INSERTs on "studentinfo" and have rows created
>> in both "person" and "student".  This requires first inserting into
>> "person", capturing the "person_id" of the resulting row, and using it
>> to insert into "student".  This seems as though it must be a common
>> situation.
>
> Have you considered using table inheritance to solve this?

No, I don't think table inheritance will help.  My actual situation is
somewhat more complicated: the view takes data from more than two
tables with a many-to-one rather than one-to-one relationship.  For
instance, consider tables "person", "address", and "phone", with a
view "person_with_contact_info" that joins a person with their primary
address and phone number, while inserting to the view should insert a
person along with an address and phone number.  In that case there is
no table that can inherit from the other to solve the problem.

Mike

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: inserting to a multi-table view
Next
From: "Richard Broersma"
Date:
Subject: Re: inserting to a multi-table view