开发者

Database design for storing Facebook likes of a user

I'm getting all the likes of the current user, and storing them to a table (user_id, liked_id). The problem is, when I 开发者_开发知识库get all the likes again and if there is a change, I just want to insert the new likes. How can I do this efficiently since many users have lots of likes?


Make the (user_id, liked_id) the clustered, primary key of the table. Use a fill-factor of the index that makes room for new pairs and make sure that your update clauses can make efficient use of the clustered index (i.e. always include the user_id in the where clause).


Yes you can make composite/ combined primary key or make combined of both field as unique. So, it will not add the data that are already there due to key error.Hence only new data will be inserted.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜