I have a photo gallery. I want to add the "Add to Favorites" button so that the user can add another user to their favorites. And then I want each user to be able to view the list of favorite users, as well as keep track of who (the list of users) added this user to their favorites.
I found two ways, and the first one:
faver_id faved_id 1 10 1 31 1 24 10 1 10 24
I donβt like this method because of 1) many repeating 2) very large tables in the future (if they have at least 1001 users and everyone loves the other 1000 users = 1 001 000 records), which I suppose will slow down my database .
The second way:
user_id favs 1 1 23 34 56 87 23 10 45 32 67 54 34 88 101
I can use these favs and explode () them in php or search if the user likes another user at the request of MySQL select count(user_id) from users where favs LIKE '% 23 %' and user_id=10;
But I feel that the second method is not very βcorrectβ in terms of MySQL.
Can you advise me something?
mysql
oyatek
source share