|
For such a scenario, no matter the way you look at it, you definately want two distinct tables. On an hierarchical level, a post is a post, and a thread is a thread, and not all attributes needed for one are needed for the other.
A truly relationnal database scheme would have to look like the one below, meaning that each piece of data should be stored at one and only one place. You can achieve that by linking your tables together when you query your database.
However, while that's perfectly fine in theory, a real-time database for a forum needs to be fast at (nearly) all costs. To achieve better performance you might want to do some caching (i.e. storing the subject, date, author, replies) in the threads table, so that the posts table and index don't have to be scanned for each thread when all that you want to do is show a forum index. In short, you eliminate a LEFT JOIN, which can be a good thing performance-wise.
Also, I've seen forums such as phpBB store their post information (author, thread, date) and their actual post contents in seperate tables. However to me it seems that the advantages of keeping the physical file size down actually do not outweight the overhead caused by the need for an other LEFT JOIN in your queries, where the database server has to do yet an other index scan. That's open to interpretation, though.
|