views:

86

answers:

2

I'm working on a not-so-big project in django that will among other things incorporate a forum system.

I have most of the system at a more or less functioning state, but I'm still missing a feature to mark unread threads for the users when there are new posts.

The thing is I can't really think of a way to properly store that information. My first idea was to create another model that will store a list of threads with changes in them for each user. Something with one ForeignKey(User) and one ForeignKey(Thread) and just keep adding new entries each time a thread is posted or a post is added to a thread.

But then, I'm not sure how well that would scale with say several hundred threads after a while and maybe 50-200 users. So add 200 rows for each new post for the users who aren't logged on? Sounds like a lot.

How do other forum systems do it anyway? And how can I implement a system to work these things out in Django.

Thanks!

+1  A: 

You're much better off storing the "read" bit, not the "unread" bit. And you can store them not as relational data, but in a giant bit-blob. Then you don't have to modify the read data at all when new posts are added, only when a user reads posts.

Ned Batchelder
Can you give an example? What do you mean by bit-blobs, anyhow?
Adi
For example, if your posts are given incrementing integer ids, then you can record which posts have been read by storing a large binary blob where each bit is a the read-bit for a post. Store that on the user record, and as the user reads posts, update the blob.
Ned Batchelder
Been working on it for a while. Unfortunately, I'm having issues with unicode. I can't really find a blob field, for some reason and "text" is the nearest option (but has these unicode issues)
Adi
+1  A: 

You might also simply store the last time a user was reading a particular forum. Any posts that have been updated since that date are new. You'll only be storing one additional piece of information per user as opposed to a piece of information per post per user.

scompt.com
Doesn't exactly do what I wanted at first, but I guess it'll have to be it.
Adi