| From: | "Michael Shulman" <shulman(at)mathcamp(dot)org> |
|---|---|
| To: | "Craig Ringer" <craig(at)postnewspapers(dot)com(dot)au> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: inserting to a multi-table view |
| Date: | 2008-06-17 03:32:46 |
| Message-ID: | c3f821000806162032t477acfdeqe907340ec70c2bf1@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Mon, Jun 16, 2008 at 10:27 PM, Craig Ringer
<craig(at)postnewspapers(dot)com(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Shulman | 2008-06-17 03:40:05 | Re: inserting to a multi-table view |
| Previous Message | Craig Ringer | 2008-06-17 03:27:16 | Re: inserting to a multi-table view |