Click to See Complete Forum and Search --> : forum viewed messages, how to make?!


infrared
August 16th, 2003, 03:53 PM
i'm making forum, any idea how to save the data, about which messages the user saw?
i want to put a little image near messages the user didn't read, and another image near by messages the user already read them.

i'm using ASP, and Microsoft SQL server.

i don't want to open a new table that will store the user_id, and Message_Id. it sounds too wasteful.

and i don't want to save the Date the user last logon, because it is not showing the messages the user saw. it only says which messages are new from the last time the user was here...

how can i do this?!

any idea?!

Thanks,

khp
August 16th, 2003, 05:02 PM
I think, the most space efficient way to do it. Would be to, for each user, store a 'date', a 'read' list and a 'unread' list.

The 'unread' list, contains a list of unread messages that are older than 'date'. All other messages older 'date' are then known to be read.

The 'read' list, contains a list of messages, that are newer than 'date' and have been read. All other messages newer than date are then known to be unread.

Assuming that message id's are consecutivly numbered, it's easy to figure out when 'date' should optimally be advanced, and what id's should be added to 'unread' and what messages should be removed from 'read'.

infrared
August 16th, 2003, 05:08 PM
in this way you don't know exactly which messages the user read.
you assume that...

khp
August 16th, 2003, 05:26 PM
Originally posted by infrared
in this way you don't know exactly which messages the user read.
you assume that...

No. Any message must be either older or newer than date.
If a message is older than 'date', and not in the 'unread' list it must have been read.
If a message is newer than date and is in the 'read' list it has been read.

There is nothing assumed about that.

khp
August 16th, 2003, 05:57 PM
I'll admit that the above solution is nowhere near optimal, in all situations. Users with a large number of old unread messages, will make the system as inefficient as simply keeping a list of read or unread messages.

To get around that you could start making read/unread lists for arbitary ranges of message id's, but implementing such a scheme quickly becomes rather complicated.