Jump to content

Storing a Facebook style 'Like' option


jetsettt

Recommended Posts

Hi all,

 

I have a website where I would like a member to have the option to 'Like' a posted article (just like the Facebook option). My current thought is to have a seperate table that holds the user ID and the posted article ID which is then queried to show how many members 'Like' a posted article by counting the matching rows for a posted article ID.

 

My question....  is this a good way to do this if there will be many 'Like' entries for a posted article, is this how Facebook would do it?

 

Another way I have seen is that comma seperated ID's for the members that 'Like' could be stored in just one field with the posted article entry which means I would not have to use a seperate table to hold the 'Like' entries. Easier option, as no seperate table required?

 

Any advice would be greatly appreciated.

 

 

Link to comment
Share on other sites

I think you're on the right track with having a relational table between each user and the articles they like.  Using a comma-separated field is most always a no-no; if your table is indexed properly, you can get the count of how many people like an article very quickly and efficiently:

 

select count(*) from liketable where article_id = 1

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.