What is the best method to determine if a user has viewed a piece of data, ie like an update to a comment. The two solutions I have thought about are these....
Use a separate table that has a row for each user and the data id that is being viewed and inserting into when the item was last viewed.
Use the same table and add a row for every user when the item is changed and delete that row when the user actually views the data.
Both methods solve the problem but in solution 2 the maximum rows for the table would at worst equal that of solution 1, no one viewed anything, and at best has 0 rows, everything has been viewed. I know in solution 2 you have no way to determine when it was viewed.
Thoughts?
Edit: I was using an update to a comment as an example. In the actual application, new users wouldn't be expected to view or read old data. It would mean nothing to them for they just joined.
It's got to be option 1:
Table 1 (comment)
Table 2 (comment_view)
Option 2 will not work because every new user will have every existing comment "marked read."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With