• sureshk 23318 (10/16/2012)


    i have a table like

    TID PID DSC

    1 0 Parent1

    2 1 Child1

    3 1 Child2

    4 1 Child3

    5 0 ParentA

    6 5 ChildA

    7 5 ChildB

    That's what's known as an "Adjacency List". They usually hold a hierarchical tree of data. An "Adjacency List" is very easy for even humans to maintain but are seriously performance challenged when it comes to processing. If it were me, I'd build a Nested Sets structure into this table for the best of both worlds.

    It would appear that you're either missing the very top level or you don't mind working with multiple trees known as a "forest". The problem with the missing the top level is that you can't actually have any DRI between the PID and the TID column.

    I also agree with the previous post... what is the actual querstion here?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)