Actually I understand the whole concept of trees and even nested sets but
I really don't know how to code a model in Catalyst that would do a job like
this.
I don't want to change the database schema since it is also used by other
applications so I think that the only solution for me is a custom model
that
would do something like
if (someuser_is_child/grandchild/grandgrand..._of(thisuser)) {
...
}
I think this could be done using the approach that Gabriel Vieira
mentiones - bottom to top...
But when I think of it - it would also be nice to have another model
with the following functionality:
@users =
list_all_users_that_are_childs_or_grandchilds_or_grandgrand.....childs_of(thisuser)
This way I could list all users top to bottom... I think that I should
use some kind of recursion
but up untill now I used the procedural approaches so I really don't
know how to code this
in Catalyst...
And another thing - I have no problems with speed. Database is not HUGE
- it's about 100-200
users so I think that any approach would be fast enough for my needs...
Naturally the most
effective solution would be nice but right now I am looking for the
simplest possible solution.
Aristotle Pagaltzis wrote:
* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2008-06-02 18:45]:
Check out Nested Trees, Joe Celko has some articles about them.
They’re called Nested Sets.
* John Tate <[EMAIL PROTECTED]> [2008-06-03 11:20]:
Along the same lines, you could look at "modified pre-order
tree traversal".
Err, that’s essentially the same thing. The data structure is a
nested set, and one of the algorithms related to it is modified
pre-order tree traversal (which is how you derive the left/right
numbers for a nested set from a tree). Referring to the data
structure by the name of one of the algorithms that apply to it
is a bit confused, though.
Regards,
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/