开发者

Keeping track of the likes of users

Take for an instance the 'facemash'(zuckerberg's) where the pictures were compared. now if i have an account for every user of mine and i am kinda doing the same thing where the user like one or the other out of many different pairs. now in the database i am using USER_ID USER_USERNAME USER_PASSWORD USER_NAME now i am having trouble in keeping the tracks of the likes that the开发者_C百科 user has clicked. In my case i might be having around 10 pairs only so i was thinking about adding 10 more columns in the user database and keeping the track of each pair by adding either 1 or 0. i know its a really crude solution but i also will have another database that will have the all the entries and keep sum of all the likes for that particular file. kindly suggest me the right way to do this?


You should create a new table for the user likes that would contain a user_id and the id of the item they liked. this is better organizationally and scalability wise. and makes it way easier to expand if later you decide you want to add more things to be liked.


I would definitely keep this information in a separate table called userlikes or something like that. Key it on the user_ID. Separate columns for each possible pair is fine. Make them boolean if space is a concern.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜