none
SQL 2008 HierarchyID data type - example and questions

Answers

  • Hi,

    * Inserting a row as the least descendant node using (NULL, NULL)

    * Inserting a row as a greater descendant node using (@Child1, NULL)

    * Inserting a row between two existing nodes using (@Child1, @Child2)

    Now we can go beck to your question:

    1. we insert Johnny (least descendant node) => 1

    2. Robert , which is greater descendant node of Johnny  => 2

    3. Alex, is insert between two existing nodes Johnny  and Robert, therefore => less then 2 and more then 1 = 1.1 (this is not less using number value but format value, we can not use 2.-1 but we can use 1.1 for "more then 1, on the same level")

    4. Niki insert between Alex and Robert => more then 1.1 and less then 2 => 1.2 since we already have 1.1

    * If we will continue to insert between 1.2 and 2 then we get 1.3 between 1.3 to 2 is 1.4 ...

    5. Steve insert between Alex and Niki => between 1.1 and 1.2 => 1.1.1

    Is this explain the issue?

    * This can give you much more understanding on using hierarchical tree without the HierarchyId. This solution was wrriten in 2001 and it almost have the same format as HierarchyId. It can give some insight I think.
    http://ariely.info/Blog/tabid/83/EntryId/135/Sorting-Parent-Childrens-data-as-an-hierarchical-tree.aspx


    [Personal Site] [Blog] [Facebook]signature

    • Edited by pituach Sunday, July 13, 2014 11:54 PM
    • Marked as answer by shiftbit Tuesday, July 15, 2014 12:42 PM
    Sunday, July 13, 2014 11:31 PM

All replies

  • Hi,

    * Inserting a row as the least descendant node using (NULL, NULL)

    * Inserting a row as a greater descendant node using (@Child1, NULL)

    * Inserting a row between two existing nodes using (@Child1, @Child2)

    Now we can go beck to your question:

    1. we insert Johnny (least descendant node) => 1

    2. Robert , which is greater descendant node of Johnny  => 2

    3. Alex, is insert between two existing nodes Johnny  and Robert, therefore => less then 2 and more then 1 = 1.1 (this is not less using number value but format value, we can not use 2.-1 but we can use 1.1 for "more then 1, on the same level")

    4. Niki insert between Alex and Robert => more then 1.1 and less then 2 => 1.2 since we already have 1.1

    * If we will continue to insert between 1.2 and 2 then we get 1.3 between 1.3 to 2 is 1.4 ...

    5. Steve insert between Alex and Niki => between 1.1 and 1.2 => 1.1.1

    Is this explain the issue?

    * This can give you much more understanding on using hierarchical tree without the HierarchyId. This solution was wrriten in 2001 and it almost have the same format as HierarchyId. It can give some insight I think.
    http://ariely.info/Blog/tabid/83/EntryId/135/Sorting-Parent-Childrens-data-as-an-hierarchical-tree.aspx


    [Personal Site] [Blog] [Facebook]signature

    • Edited by pituach Sunday, July 13, 2014 11:54 PM
    • Marked as answer by shiftbit Tuesday, July 15, 2014 12:42 PM
    Sunday, July 13, 2014 11:31 PM
  • That clears it up.  Thank you.

    Tuesday, July 15, 2014 12:43 PM
  • You are most welcome :-)

    [Personal Site] [Blog] [Facebook]signature

    Tuesday, July 15, 2014 2:17 PM