Creating a flexible hierarchy

How do I create a table structure and query that allows for a flexible hierarchy of records. For example, in a forum type of environment, I have a table that is

t1.id, t1.message

Then a relate table that is a parent/child as
parentid, childid which are both t1.id numbers

So if the table were populated with


1  2
1  3
2  4
2  5
4  6
6  7
8  0 (0 being no children)
9  0

And I want to display


1
   2
      4
         6
            7
      5
   3
8
9

So is this the correct table structure and if I do it like that, is there a way to do the query to return all the records in this hierarchy order?

Thanks

Create a belongs_to field that contains the id of the parent.

Makes sense, that saves a join on any query. Is there a way to build the hierarchy with a single query or does that need to be an iterative process from php?