[RESOLVED] Forum Help - Thread/Post Storage
I am making a small forum for my website and i am not sure of the best way to store posts and threads.
Should i store them all in one table and just have a field "parent" that if it is blank it must be a thread and if not, it is a post.
Or should they be in separate tables?
I think that when they are together it makes it easier for me to count the number of posts and thread on the main forum page.
http://www.rapidfriends.com/forums.php That is what i have so far.
Re: Forum Help - Thread/Post Storage
never mind! i decided to go with them all in the same table.
rep was distributed accordingly :)
Re: [RESOLVED] Forum Help - Thread/Post Storage
I thought I replied to this last night. In my imaginary reply I said that you should put them in two tables. It will reduce redundancy and overhead (i.e: when moving threads).
It also means it is more normalized.
Re: [RESOLVED] Forum Help - Thread/Post Storage
Threads are not posts. They must be in separate tables. The data that you store in each case is quite different.
Re: [RESOLVED] Forum Help - Thread/Post Storage
FroumID, Number Of Replies, Thread Starter, Post Time, Rating, Deleted Flag
All those are the data you are likely to find in a thread.
Re: [RESOLVED] Forum Help - Thread/Post Storage
And the title, of course.
Mind you, I'd be inclined to omit the 'number of replies' field, and use an aggregate instead.
Re: [RESOLVED] Forum Help - Thread/Post Storage
Quote:
Originally Posted by penagate
And the title, of course.
Mind you, I'd be inclined to omit the 'number of replies' field, and use an aggregate instead.
Duplication in favour of efficiency.
Re: [RESOLVED] Forum Help - Thread/Post Storage
Bah. Not worth it for a count field.
Re: [RESOLVED] Forum Help - Thread/Post Storage
Certainly is - a single SQL query creates a lot of overhead. In a forum it is better to do that during the update rather than the recall. :D
Re: [RESOLVED] Forum Help - Thread/Post Storage
Disagree. Row count is a quick lookup. Also, executing it as a single query would be foolish. It would be done as part of the query to fetch the list of threads for a forum. Nil overhead.
Re: [RESOLVED] Forum Help - Thread/Post Storage
If you are just fetching a list of threads you do not need a relational link to the posts table. If you want to count the number of posts in the thread you'd need to link up with the table and consequently deal with more records.
Assuming anyone actually replies to the thread.
Re: [RESOLVED] Forum Help - Thread/Post Storage
ok thanks you guys for the replies, but this is just a tiny little forum for my small site. i dont need anything fancy. All deletes are deleted right away, i dont need any bells and whistles added. :)
One table works fine for me.
Re: [RESOLVED] Forum Help - Thread/Post Storage
Quote:
Originally Posted by visualAd
If you want to count the number of posts in the thread you'd need to link up with the table and consequently deal with more records.
Actually, you're right. I wasn't thinking, but you would need a predicate to count the replies. I suppose my logic only makes sense if each thread had its own table of replies, which would be idiocy.
Quote:
Originally Posted by visualAd
Assuming anyone actually replies to the thread.
I'm sure dclamp can reply to his own threads. :)
Re: [RESOLVED] Forum Help - Thread/Post Storage
Why have a "forums" on a social networking site? Seems illogical.
"RabidFriends" Is it a site for friends with th rabies? :D
Re: [RESOLVED] Forum Help - Thread/Post Storage
Quote:
Originally Posted by RobDog888
"RabidFriends" Is it a site for friends with th rabies? :D
deja-vu... yes, rabid people come together and talk about their stories... :)