I'm trying to construct a article page, where people can rate the article. Currently, I have a table Articles, that stores the articleId, articleContent, and few other information. And a Rating table where I store userid, articleid and rating.
userId, articleId, rating
My worry is, there can be several users rating, several articles. The Rating table is growing exponentially. There are NxM entries in my rating table for N users and M articles.
Is there a better way to design my database, so I won't run into a huge Rating table, and help reduce the time the below query takes to run.
select sum(rating)/count(*) where articleId = 'x' -- to calculate the average rating for a give article
Thanks in Advance!!!
View Complete Post