Skip to Content
avatar image
Former Member

Parent-child hierarchy

Hi All,

Can any one explain me Parent child hierarchy with example?



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jan 21, 2013 at 08:26 AM

    Hi Pooja,

    There are 2 types of Hierarchies in HANA:

    1. Parent Child

    2. Level

    Parent Child hierarchy is one where you have one child field and one parent field. For example, let's say we have a table in which we have the details about the employees of a department and there sub-ordinates. Now there are only 2 fields in this table: 1. Child; 2. Parent and the data is as follows:

    Child          Parent

    Matt          ?

    Brian          Matt

    Joe            Matt

    Kelly          Brian

    Kate          Joe

    Here in the above scenario, Matt is the ultimate boss of the deparment. Matt has 2 sub-ordinates: Brian and Joe. Brian and Joe have Kelly and Kate as their respective sub-ordinates.

    Now, this kind of hierarchy is known as a Parent Child Hierarchy. When you need to model this kind of hierarchy in HANA you need to make sure that all the nodes of the hierarchy are present in the Child column atleast once. And the top most node should have Null as its parent.

    On the other hand Level Hierarchy will have following kind of structure in your base table:

    Level1           Level2          Level3

    Matt              Brian           Kelly

    Matt              Joe              Kate

    Here you can see that the data is organized based on there level into different fields. So when you need to model a Level Based Hierarchy in HANA, you need to know the maximum depth of the hierarchy. i.e. if in future, Kelly and Kate have sub-ordinates assigned to them then the level hierarchy structure needs to be modified (adding Level4 in the structure) to include those new sub-ordinates as well. But in case of parent child hierarchy, this is not an issue as there will always be only 2 fileds (Child and Parent) in the hierarchy structure.



    Add comment
    10|10000 characters needed characters exceeded