i'm a young self-thought web dev from morocco to cut the story short i'm working on a special social media project i learnt coding through but it developed into a bigger project over time. i reached a point where i want to create proper analytic tools for my posts
so this is the post with the stars rating slide i'm storing it in an sql database with (user_id, post_id, stars) but i was wondering do i have to count() everytime a user fetch the post ? or there is a more efficient method to display post analytics cause i've read a lot but didn't find a solution to my case and i don't have a corporate experience to solve solutions of this scale. everytime i request the post i have to count the sum of stars and num of voters and then i do (stars/voters) to get the average and i don't know if it is a good idea to count everytime the post is requested but i'm not sure how to do it any other way.
- i have another place where i have to count views and i also don't know how to calculate them in a more efficient way. i'm open to all suggestions