I am working on an article manager, in which i want to use a rating rating (normal drop down select box with 1 to 5 value)
OPTION 1
To create this i have two options. Either i can use a rating table (a separate table in addition to the article,news,quote etc table) and keep all the ratings in it(for whole site)
Or
OPTION 2
I can have rating field in each (article,news,quotes etc. ) table and store the corresponding rating data in that.
I have different sections like quotes,articles,story,news etc. and the id is unique in a particular section. But if i use the 1st option then i will have to store article1,article2,news1,news2 etc... to identify the article and news. But in 2nd case i will just use id 1,2,3. ..
Please suggest which way is better/preferable keeping in mind that i would have enormous amount of db data in future.
Rating Of articles
Moderator: General Moderators
If you use the second method you'll need two columns - one to store the aggregate value of all the ratings, and another to store the number of ratings to date. So when someone rates an article as 4 stars for example you'd add 4 to the aggregate column and 1 to the number of ratings column. Then you just need to divide the aggregate by the number of ratings to get the current average. Of course that assumes you're using a basic "mean average" for the current score.