Answer the question
In order to leave comments, you need to log in
What is the best way to organize a record in the database (likes system)?
What is the best way to organize records in a table with likes.
I do this: let's say there are two fields in the table id_user and id_article,
id_user is the id of the user who
liked it id_article is the id of the post that was liked
How is it better to store?
Option 1:
id_user--------id_article
1---------------1,3,4,7,...
and then check the array from id_article whether there was a like from this user or...
option 2:
id_user--------id_article
1---------------1
1------------- --3
1---------------4 1-------
7
and then just look for the entry in the database by id_article
Which method requires less resource consumption?
Answer the question
In order to leave comments, you need to log in
If you have such a question now, then you are writing the first version of your script, and if so, then you need to stick to the 3rd normal form .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question