Posted by ponyxprs on April 5, 2013 at 6:00pm
So... What should be stored in a forum post? Whether it is a node or entity, what should we store? And how?
So... What should be stored in a forum post? Whether it is a node or entity, what should we store? And how?
Comments
So I have 2 Items, I don't
So I have 2 Items, I don't want to call them nodes or entities just yet.
1) Forum post, Every user entered message in a forum is a 'post', thus it makes sense to start with the smallest building block, a 'forum_post'
post id - unique id for the post
topic id - id for which topic the post belongs to
forum id - id of what forum the topic is in (will make sense later with global announcements, possibly)
user id - the author who posted the post
user ip - the IP address where the post came from
post time - time of the post
post subject - Subject of post
post text - Text body of the post
post teaser - teaser or description of the topic of the post (used in the meta tag description)
maybe more
2) Forum Topic, Every post has a topic, even if it is a one post announcement.
topic id - id for this topic
forum id - id of what forum the topic is in (will make sense later with global announcements, possibly)
user id - the author who started the topic
user ip - the IP address where the first post came from
topic time - time of the first post
topic status - locked, etc...
topic type - sticky, announce, etc...
topic first post - first post id of the topic
topic first poster id - the id of the first poster
topic subject - Subject of the topic
topic description - I was thinking of using the 'post teaser' of the first post for this
topic last post id - last post in topic
topic last poster id - id of last poster
topic last post time - time of last post
maybe more
There are still two more levels to go up. Some call them 'forum' and 'containers'. I am not sure if node or entity would work for these, but generally they have the same structure, just one is a parent of the other.
.
Looks quite good to me. Two questions though:
1) Do we need a post subject or is it something we can leave for people to add if they need one? A thread topic is obligatory, but it seems that most of the time there isn’t anything useful to enter for a post and people leave it empty anyway.
2) How did you plan to handle the teaser? Is it something the user enters? If not how is it generated? Is it like the first x words of the post? Depending on what you want to put in there we may not need a separate database entry for it.
As for the forum/containers… they could again be either node or entity. I guess they could be some form of taxonomy too.
1) Not 100% sure on the 'post
1) Not 100% sure on the 'post subject' . Most people don't use it like you said and just leave it blank. I know later versions of phpBB3 fill the first one with the topic title, and subsequent ones with "Re: title" so one page of 20 replies you have 1 title and 19 RE: Title. I am not sure this is good for SEO. However you would need a title for viewing a single post, if you ever wanted to break one out and put it elsewhere on the site.
2) I am not sure again. How does Drupal create a teaser? I would have to look at that and see if it would work for the posts. I think I will also give the users an option to write their own 'teaser'. It might come in handy for some forum admins. But I don't think I will call it teaser...
Still up in the air for the rest. I think a description for the forum is needed, but I am not so sure one would be needed for the containers, but some admins may want it, so it will probably get one as well.
John
.
I did some more thinking on the subject.
1) I realized that if we go with nodes we get a title field no matter what. If we go with a fieldable entity people can add a title field if they need one – and have the flexibility to use something like token/php field instead of a regular text field if that suits their needs.
2) If you mean the standard drupal teasers those are just another display type like ‘full’ or ‘rss’ – the user can basically say what fields he wants to use, how they are formatted, ect.
I also overlooked the other day that ‘user id - the author who started the topic’ and ‘topic first poster id - the id of the first poster’ will always be the same, so we can drop one of them.
Forum descriptions sounds like a good idea. While people could always add such a field to a node/fieldable entity I feel that forum descriptions are a common enough feature to provide anyway, even when it’s just displayed in the backend.
1) When you say people, are
1) When you say people, are you talking about a site admin or a user posting a message on the forum? If the latter, they don't get much of a choice when posting a messsage. Now if you mean site admin, that is something to think about.
2) Ok, will look at that as well.
As far as having 'user_id' in the forum_post table/entity/node, and 'topic_first_poster' in the forum_topic/entity/node table. It is a performance issue, take alook at the index page for any busy forum, or the topic listing for any forum. It will show anywhere from 15-50 topics, depending on how the admin sets up the view. Now each topic listed usually shows Title, who started it and when, and who last posted and when. If you store topic starter and last poster with the topic data you only need one query. If you store them seperately you now have 3 queries. This is for each topic listed. the added querry to update the topic when someone posts is minor compared to the increase in querries for the index. The index page and 'view forum' pages are hit many more times then posts are made.
1) I was talking about the
1) I was talking about the site admins, yes.
I understand your issue with the query times, however that’s not what I meant. In your topic table you have both ‘user id - the author who started the topic’ (3rd entry) and ‘topic first poster id - the id of the first poster’ (9th entry) however the id of the user who started the topic will always be the same as the id of the user who made the first post, so we only need one of the two columns.
To avoid unnecessary queries we might want to store
user_name (for posts)
topic_first_poster_name (for topics)
topic_last_poster_name (for topics)
as well though, so we don’t have to query their username from the user table for every post/thread.
Thoughts about Forum Entity/Node
Some suggestions for the forum entity/node. Still not sure about the containers myself. Maybe a taxonomy to group the view with would already be sufficient.
Potential fields for the forum entity/node:
forum_id – primary key
parent_id – id of the parent forum
title – title of the forum
description – description of the forum
delta – the sequence number of this forum, for displaying purposes
last_author_id – id of the last person posting in the forum
last_topic_id – post_id of the last posting in the forum
last_post_time – unix timestamp when the last post was created
Potential normalization candidates:
topic_count – number of topics within the forum
post_count – number of posts within the forum
last_author_name – username of the last person posting in this forum
last_topic_subject – title of the last post in the forum