Unique meta_key with array value vs repeated meta_key with single values

Let’s say I want to build a function that allows my users to like posts in my website.

My intention is to store the ID of the user that liked the post as metadata.

My question is what’s the best way to go in terms of performance and ‘queribility’.

Separate row for each like:

‘liked_by’=>’3’
‘liked_by’=>’21’
‘liked_by’=>’17’

Or just one row to hold a serialized array (json) with all IDs

‘liked_by’=>array(‘3′,’21’,’17’)

Considere I would like to store the date of each like too.

array( $user_id => $current_date )

Else take in consideration that I most ensure that all post metadata is useful for queries!

Read more here:: Unique meta_key with array value vs repeated meta_key with single values

Leave a Reply

Your email address will not be published. Required fields are marked *