storing forum threads and replies in a database
18:59 15 Feb 2009

A forum seems to be an interesting project in terms of schema design.

What is the best way to get a recordset consisting of an opening thread and replies?

I could store all threads (the first, opening post) in a table and have a table with replies. I could then use the appropriate join to get all the replies in the reply table which match with the thread (e.g. unique key match between pk/fk). I could then sort this table based on data of replies to get the start to last post.

Would this be a view or temporary table?

And why?

Alternatively, I could store everything in one table and use recursion to get the data back.

Is this a little more complex?

What is a better way than both of these?

database-design