[SQL] Best way to store Master-Detail Data - Mailing list pgsql-sql

From Alvin Díaz
Subject [SQL] Best way to store Master-Detail Data
Date
Msg-id BN6PR17MB13800E701DD70F7449956699E7020@BN6PR17MB1380.namprd17.prod.outlook.com
Whole thread Raw
Responses Re: [SQL] Best way to store Master-Detail Data  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: [SQL] Best way to store Master-Detail Data  (Andreas Kretschmer <akretschmer@spamfence.net>)
List 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.




pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: [SQL] CTEs and re-use
Next
From: "David G. Johnston"
Date:
Subject: Re: [SQL] Best way to store Master-Detail Data