I would like to build a website that has some elements of a social network. So I have been trying to think of an efficient way to store a friend list (somewhat like Facebook).
My application uses some kind of \"virtual folders\" so I need to store the tree structure in the database. The table holding the data is quite simple, it has 3 columns:
Ok, so this shouldn\'t be difficult, however I have encountered weird and bizarra flukes. I am trying to pack a tree into an array, where each node is something like:
Any node can have any number of children. To search this tree i wrote something like this function Search(key, nodes){