There is a table "users" and "movies", as well as a general table "viewed". In the "viewed" in the id_film column there is a recording of the id of the movie separated by commas. How then for example on the user page to make a conclusion of all these films?
- normal means in any way. Relational databases are not intended to store anything separated by commas. This breaks the 1st normal form. ru.wikipedia.org/wiki/ ... it is necessary to normalize the database by creating a separate table of the id-movie id user type (single) - Mike
- 2Possible duplicate question: Explode in MySQL query - Mike
- And if, for example, not through a comma but through a sign | will it be the same? - bp_gusar
- of course. The comma is basically a bit better than the rest, because the find_in_set is sharpened on it. but the fundamental impossibility to work with such a table on the index lowers the performance below the plinth. And the correct table firstly will give greater performance, secondly it will make adding / deleting easier (because you just add a new record and you don’t need to stretch the entire row and add value, I’m generally silent about deleting from the row. And then you’ll can easily add a field to fix the vote for the film, add to favorites or something else - Mike
- I think you can get a string with id movies separated by commas, iterate through it as an array created using explode, and make a query to the database in each loop with a sample of the current id. But of course it is better to use the advice of Mike. - Plikard
|