Let's say I have a MySQL table that is something like this:
software table:
id int
name text
votes int
rating int
Where votes would be the number of times someone has voted for that item and rating would be the average of those votes.
Example data:
id: 0
name: FooBar!
votes: 5
rating: 3
Now another user comes along and rates this a 1. How would I caculate the new rating? would be be better to just make another table and enter a new row every time someone votes like
id int
software_id int
score int
user_id int
and then calculate the re-calculate the average rating every time? I would think it would take a toll on the server.
Second question:
I'd like to be able to order the software by the highest rated but I don't want a program with an average 5 star rating but only 1 vote to rank higher than a program with an average of 4 with 893 votes. How would I accomplish this?