Forums

Saving to Master/Details tables

adop 01 Jun, 2012
Hi Bob,

I have to manage contracts of different types where there are 2 types of data:
1) some info is common to any type of contract. This would be for example: cf_id, cf_created, cf_ipaddress. But also others like country_code, date_of_signature, etc.
2) other info depend on the contract type. For example if its a car purchase there would be car_model, car_manufacturer, etc., while if it is a house purchase I would need to store square ft, address, etc.

Ideally I would like to store all type 1 info in a master table and type 2 info in a details table and there would be as many details tables as contract types.

So every time a form is saved some fields should be saved to the master table and others to a details table.

In you experience is this possible and in case could you give me some directions how to implement it?

Thanks,
adop
GreyHead 02 Jun, 2012
Hi adop,

That's pretty much exactly how I would do it. The main thing is to link up the data so that you can retrieve it. Your main 'type 1' table needs to include a 'type' column so that you can tell which 'type 2' table to access and the 'type 2' table needs to include a 'contract_id' column with the id from the 'type 1' table in it to tie the sub-record to the main record.

You should probably also check out the MySQL manual on Joins to get an idea of how these work.

ChronoForms Model IDs will do most of the work for you though you will have to do some pre-work to in a Custom Code action to get the data into the correct format.

Bob
This topic is locked and no more replies can be posted.