Hierarchical SQL
Subject:   How about using integer type for path?
Date:   2004-08-19 01:44:10
From:   Carfield Yim
I think we can integer type for path, let say we allow 100 organizations in same level. We can multiply 100 for each level of organization like:

/ \
/ \
Bert Chuck
/ | \
/ | \
/ | \
Donna Eddie Fred

emp_name emp_id path
'Albert' 'A' 10000
'Bert' 'B' 100
'Chuck' 'C' 200
'Donna' 'D' 201
'Eddie' 'E' 202
'Fred' 'F' 203

Then we can select all item under under 'C' as:
select * from Personnel_OrgChart where path > 200 and path < 300

And all the other operation can do in interger calculation. How do you think about this? As it don't involve String operation, will it run much faster?

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • How about using integer type for path?
    2004-08-19 05:21:31  --CELKO-- [View]

    I cover versions of that method in the book, too. It works fairly well for static situations in the real world. That is, if the tree does not get too deep or too wide.

    You can also use a bigger gap than one in a nested sets model to speed up insertion by saving reorganization.