SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Complex object relations and howto populate child objects?

    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:

    Code:
    Customer
       CustomerId (PK)
    
    Order
       OrderId (PK)
       CustomerId (FK)
       OrderStatusId (FK)
       OrderIdentification
       CustomerReference
    
    OrderStatus
       OrderStatusId (PK)
    
    RestorationUnit
       RestorationUnitId (PK)
       OrderId (FK)
       BlockId (FK)
       UnitIdentification
       Case
    
    RestorationPart
       RestorationPartId (PK)
       RestorationUnitId (FK)
       ColorNumberID (FK)
    
    Block
       BlockId (PK)
       BatchNumber
    
    Color
       ColorId (PK)
    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?

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by axelR View Post
    I donīt know how to populate the parent object with their children objects from the large result set.
    are you asking what to do with the result set after you get it from the database?

    if so, this isn't a database question, is it

    which forum would you like this thread moved to?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Application Design

    Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •