SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Table design problem

    Hi Guys,

    Imagine this senario:

    Parent 1
    Child 1
    Child 2
    Child 3
    Grand Child 1
    Grand Child 2
    Child 4

    Parent 2
    Child 3
    Grand Child 1
    Grand Child 2
    Grand Child 3
    Grand Child 4
    Child 5
    Child 6

    Parent both parents use Child 3 and have there own different children. Also Parent 2 adds to Child 3

    How could I manage the fact that I do not know how many levels will exist and Children can be part of many parents, items can basically be added at any level.

    Thanks for the help.

    Sinky

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could specify each node in an XML file. Each node could have 2 attributes, hasChildren and hasParents, in which you would enumerate all child and parent nodes.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thanks for the reply.

    Thats sounds like a good idea but my solution really needs to be database based.

    Thanks

    Sinky

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    because of the multiple parent thing, it will be very difficult to retrieve entire sub-trees with a single query; you'll have to use multiple queries in (gasp!) a loop. this will not scale well.

    will that be a problem?
    Check out our new Industry News forum!
    Keep up-to-date with the latest SP news in the Community Crier

    I edit the SitePoint Podcast

  5. #5
    SitePoint Addict Mastodont's Avatar
    Join Date
    Mar 2007
    Location
    Czech Republic
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it will be very difficult to retrieve entire sub-trees
    But sub-trees grow up from one root, don't they? Sinky should say what graphs he wants. If he wants graph for Child3, he can go with one sub-tree up and with another down.

  6. #6
    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 sinky View Post
    Parent both parents use Child 3 and have there own different children. Also Parent 2 adds to Child 3
    could you explain how Child 3 can have 4 children but Parent1 is not the grandparent of grandchildred 3 and 4

    that doesn't work, does it

    i think it should be shown like this --
    Code:
    Parent 1
      Child 1
      Child 2
      Child 3
        Grand Child 1
        Grand Child 2
        Grand Child 3
        Grand Child 4
      Child 4
    
    Parent 2
      Child 3
        Grand Child 1
        Grand Child 2
        Grand Child 3
        Grand Child 4
      Child 5
      Child 6
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •