Best way to store Master-Detail Data

From: Alvin Díaz <alvin(dot)rd(at)live(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Best way to store Master-Detail Data
Date: 2017-04-13 03:51:36
Message-ID: BN6PR17MB13800E701DD70F7449956699E7020@BN6PR17MB1380.namprd17.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi.

I wan to to know if someone can recommend me the best way to store
header and detail data
in the same function.

For example:

I have a table for purchase orders headers and a table for the detail
then i want to record
the header and detail under the same function to make sure that both
header and detail
are committed or not.

What i usually do is create a function with such as parameters as fields
in the header table and
after that, i add a same data type parameter for each field in the
detail but as an array.

In the function, i insert the header data, after that i use a loop on
the first array parameter,
how each array parameter has the same length, i use the ordinal position
to insert the lines.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2017-04-13 04:15:29 Re: Best way to store Master-Detail Data
Previous Message Rob Sargent 2017-04-12 16:29:25 Re: CTEs and re-use