[wp-hackers] Like Posts - Store Data in DB, User_Meta or Post_Meta

BenderisGreat greglancaster71 at gmail.com
Wed Nov 13 14:34:30 UTC 2013


What Andrew said about duplicate data being dangerous got me thinking, and I
am now wondering if there is an more efficient way to store some
information.  I have an activity feed that updates whenever someone does
something, and it stores the time it occurred, the action_name, the user_id,
and an additional data field I included so I could easily echo out
additional information.

For example, someone likes a post.  That gets stored in the db table
'post_likes' along with the user_id, post_id, and datetime.  At the same
time, an activity_tracker() function updates the table with the user_id,
activity_id, datetime, and and data_field that stores additional information
(for this example, lets say its the post_id).

Then on the page I call the activity_message() function which queries the
activity_tracker() and displays their activity.  The extra data field I
mentioned (post_id) is used to echo out the name of the post a user liked. 

Is there a smarter way to do this?  Maybe a table join to reduce the number
of sql queries, and stop the need to store additional (redundant) data just
so it can be echoed out?  If I don't store duplicate information in the
tables, there is no way for me to associate the post_id that was liked with
the activity_type, user_id and datetime. 



--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Like-Posts-Store-Data-in-DB-User-Meta-or-Post-Meta-tp42769p42817.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.


More information about the wp-hackers mailing list