This is a difficult subject, certainly beyond the scope of postings we can do here.
You should obtain the book, "Joe Celko's Trees and Hierarchies in SQL" for a thorough treatment of the subject. You can also look in his book "SQL for Smarties" where he discusses the basic concepts of representing a tree in an SQL database.
You might also try Google for "SQL Nested Sets" and "SQL Adjacency List".
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com