hey well ive been trying to get something like vb's category and forum system to work but i cant

can someone explain to me how to accomplish something like a category and then things under it. i have looked at vb's code for forming the forum list and i see its all done in one query, so i was wondering how does it determine what is a category, what is a forum, and how to place them.... can someone please help