I'm working on a project with an existing database. One of the main features of the app I'm developing is to show a specific customers orders. These orders have complex relations to other objects:
This is a simplified description of the object and some of their attributes (those of relevance to the mapping) that have a relation to orders:
So I want to present Orders.
The Order have an OrderStatus.
The Order contains many RestorationUnits and each RestorationUnit is a collection of many RestorationParts, and each RestorationPart has a specific Color.
For the RestorationUnit I want to present which Colors it contains ( depending on which RestorationParts it contains).
Each RestorationUnit also have a Block with a BatchNumber
So until now I have made querys like "getAllOrdersByCustomerID()" and foreach Order, getAllRestorationUnits() and foreach RestorationUnit, getAllColors().
And say I want to get 10 Orders, with each 5 RestorationUnits and get their Colors by RestorationPart, thatīs already 50 querys.
Now say i do some JOINS, i could get the query count down, but my problem is that I donīt know how to populate the parent object with their children objects from the large result set. How is that done in a good way? I guess there is some standard algorithm for doing this type of object population? How do the ORMs do these things?