Jump to content

Forum Posts Database Design


AbydosGater

Recommended Posts

Hi, I Hope I do have the right section for this!

 

I am currently working on a GWT Based AJAX Application with a PHP/MySQL backend.

One of the features I wish to add to my application is a forum for the users.

 

My query is to how forum systems such as phpBB, SMF, or vB implement the "unread topics/posts" feature.

EG: When I visit this forum and open a board such as this Application Design section, the forum knows which topics I have or have not read.

 

I was wondering how this was implemented?

 

The first thing that came to my mind was that every time a user opened a topic, a row was inserted into a db table that recorded the users id and topic id that could be checked against later.

But surely having a list of every topic the user has viewed and checking against it is a very unefficient method?

 

Is there another way to accomplish such a task?

 

Also, what would happen if a change was made to a topic, such as a new post? Would the forum need to loop through every record of every users visit to a topic and if the user has visited this topic remove the record so that it appears as unread to the user?

 

Any advice?

 

Thanks,

Andy

Link to comment
https://forums.phpfreaks.com/topic/183072-forum-posts-database-design/
Share on other sites

  • 3 months later...

The OP probably has the method right.  As far as efficiency is concerned you'll notice that the "unread topics" only lists 3 pages of topics, i.e. the current day's topics.  It doesn't list every topic ever posted.

 

There is probably a cron job to remove entries from this table every day at midnight or something.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.