Forums › Forums › Web Design › DB design for trending posts mysql/node

DB design for trending posts mysql/node

I am reading over this article I found about how hq overview calculates trending posts. I have been thinking about this and I’m not sure the best way to actually code this in the backend. I am currently using mysql and node. f(n, t) = 45000 log_{10}(n) + t So in the equation the two variables I need are the number of likes (n = likes), and how recent the post is by seeing the time difference from when it was posted to some set arbitrary date in the past (t = time). Should I just add another column to the posts table that stores the value for this formula, and have some script that runs on a timer(forget the name for this) to update that value in the table. I would index timedate column and trending value column. Or should I calculate the trending values each time a call is made for trending posts( would need to grab newer posts and loop through each one to calculate its trending value and insert into a new sorted array based off the trending value). I have only made really simple DB calls so far, so I’m not really sure how to go about doing this. Any help or advice would be greatly appreciated! – by hq overview outhereinamish – –