ESSENCE IN THE NEXT ... There is a table. From it, according to certain criteria, data is sampled by a custom filter.

How to implement a functional, viewed / unread data Those that the user opened and viewed the rest (unvisited)

client part on JS - everything is clear ...

But as part of the database on the server ... Edit the main table with the data and assign viewing / non-viewing there, because the data is ONE FOR EVERYONE (that is, not as private messages), but the filter can be different

Ie it is necessary to create a separate table ...

I thought so, by default everything is considered unvisited.

Next we create a string, with the user ID, and the ID string of the sample and 0 or 1 - view / non-view ...

But then you get a lot of these lines (number of users X per number of lines)

I'm afraid that there will be a performance ...

Maybe you can make it easier?

  • 3
    You do everything right. - sinedsem

1 answer 1

All right, just enough two fields: user_id and data_id . Unit / zeros are not needed. There is a pair in the table - the record is viewed. No record - read and read!

Easier - you can "optimize" in every way, but everything has its own price. For example, to “remember” only about the last 32 or 64 articles on the site, say: and store three more values ​​in the user table: two 32-bit numbers (1 — read, 0 — not) and the id article, from which these bits are counted. At each visit, update these user parameters. (crazy method, invented on the go)