Article Ranking System - PHP, MySQL
Hi
I'm starting to develop a website that allows users to rate articles. I am currently stuck with a bit of a problem.
Do I store a rating for each article from each user in a table and query it every time I want to know an articles rating, or I want to know a users average rating?
OR
Do I store these in the article and user tables so that I don't have to query the database as heavily every time I wish to know this data?
OR
I could do both and update the ratings every time a new rating is added. This would mean that the database isn't over-queried every time a user loads a page.
Any insight would be really helpful :)
Dan
Re: Article Ranking System - PHP, MySQL
The answer all depends on how much data you want in the future. If you can say 100% that you will never need to know how many times an article was rated or by whom...then you can average them.
Personally, I would store all ratings in a table and query. You never know when you're going to look back and wish you had that data all along. There's no way you're going to overload your database unless you are querying wrong and have millions of users connecting per minute.