I have a news table for 3 levels o开发者_JAVA技巧f users and there is a field called type in news table that holds corresponding level values. When users log into their panel, if there was news for their level, system shows it and they can read it.
The problem arises when users read news and sign out of system and then return back and see read news again!
How can I design my system to solve this problem and let individual user mark posted news read randomly and he/she doesn't see them again on next log-in?
You can create a separate table that links news to users. Every newsitem read is put in that table. So the existance of a record in that table marks the specified newsitem read by the specified user.
If you got many users and much news, this table might grow fast, although I think it will take a while before you reach a critical number of rows. (How many users you got?)
A solution would be to delete those records after a while. You will probably only display news of the last few days, so after that period is passed, you can delete the crosslinks, because you won't need them anymore. If a user were to scroll back to read the news of the past, it won't matter whether they've read it or not.
Add a table oldNews
with two columns: userID
and newsItemID
. Every time a user sees a news item, add an entry into this table with their ID and the item's ID. When displaying, just do a search that the corresponding row isn't in the table.
精彩评论