I'm working on my own from-scatch forum, and I've hit a brick wall with this. I want to have unread/read icons, like most forums do. However, I don't want to use the typical "check last visit time against post time" method, because this only shows new topics since the last visit. I want anything you haven't read to remain unread until you physically read it (or hit the "mark all read" button). I know this is possible without making a gigantic database, because I have another site with a phpbb forum that has a hack installed that allows this, and it doesn't have any such huge database problems.
I've only been able to come up with two ways to do this, and I could really use some ideas. Here's what I've got:
First way. All threads show as unread upon registration. Once a user clicks on a thread, a entry is created in a "read_topics" table with user_id, thread_id, and last_post_time for the thread. Then, anytime the user visits the forum, all threads are checked against that table, and if they aren't in there (or the post time is different), then they're marked unread. However, this seems like it could quickly create a gigantic database. Some users might read thousands of threads. If you get a few hundred users doing that, it would be massive. Or am I undestimating a good indexing's ability to handle a database like that?
Second way. In my users table, put two new columns for each user. One for unread topics, and one for read topics. Every time a user logs in, check all threads' last post time against the user's last visit time. If it's new, add the thread_id to unread_topics. When the users views it, add the id to the read_topics field with a timestamp of the last post. Then, everytime the users looks at the forum with the list of threads, it checks those thread_ids. If it's greater than the last visit time, it checks to see if it's in the read_topics field (so that it doesn't get marked unread twice in the same session) and if it IS in the read_topics field, it checks to see if the timestamp of the last post is the same. If it's not the same timestamp, it goes back in unread_topics. If it is the same, then it stays unread. To keep the read_topics field from getting massive, every time you log in it would run through all the topics in your read_topics field, and if their last post time was earlier than your last visit time, then it would remove them from the read_topics list since they don't need to be there anymore.
I'm not really leaning toward either way right now. The first way is much simpler, but it seems like it would become a huge resource hog. The second way seems like it would be the better way to go, but it looks like a headache to code.
Anyone have any other ideas? It seems like there should be a more elegant way to do this, but I'll be damned if I can think of it. I know it's possible, though, because I've got a hacked phpbb forum that's doing it.