MySql: how can I implement some read / not read yet topics?

I am going to implement a list of topics / arguments on my forum, and I would like to add a read / not read flag for each post for each user on each site.

I think with such things: a table watched_topicswith id(INT), user(VARCHAR)and topic_id(INT). When a userbrowses the page, I insert (if the data does not exist) this data.

When another userwill insert a new message into the topic, I will delete the watched_topicsentire row with this from the table topic_id.

This can cause problems: think about 9000 topics and 9000 users who viewed all topics: the table will be so large ( 9000x9000 = 81000000 ).

So, I believe that this is not the best strategy for implementing this kind of thing! Any suggestion would be appreciated :)

Greetings

+3
source share
3 answers

Your suggestion sounds good. I would make the custom field also a foreign key - this gives you a little more flexibility.

Are you sure that all 9000 topics are read by all 9000 users? I mean this reality? As you said, post topics are deleted when a new post is added. And when that happens, another 9000 entries are deleted :)

I would index the table and go with your suggestion (with user_id change). If the size of the table is bothering you, you can always change the implementation later. Most likely, this will never be a problem.

+3
source

Can a different approach be proposed?

Use the web browser history mechanism.

URL- , . , .

, , , , CSS . , .


- , , , , .


, , , .

+4

: , . , , msg .

+1

Source: https://habr.com/ru/post/1788458/


All Articles