I want to represent user in some hierarchy for fast search,
I am planning something like below
<root>:<parent>:<group>:<user>
1:123:154:11
1:123:154:12
1:123:152:13
1:124:159:15
1:123:153:14
2:125:150:10
2:124:149:19
function template
isValid(pid, myid){
}
Where, this function first myId will be any next level ID and, pid will be imediate partentID .
or both will be my IDs only .
//myid belongs to proper pid
isValid(154,11) => true
//myid belongs to proper pid
isValid(154,13) => false
//myid comes under proper pid
isValid(123,154) => true
isValid(154,123) => false
//Here I gave root ID as pid,so still valid
isValid(1,154) => true
isValid(154,12) => true
isValid(150,19) => false
**this is major problem when user skips
when 123 gives his pratner ID and and trying compare with 159 it should return false
1:123:152:13
1:124:159:15
isValid(1,159) => false // This is becoming conflicts with my way of hierarchy define
My user level also grows so I want to know given a hierarchy check for user id and pid must be valid in hierarchy ?