Q:

PHP/MySQL: Rating system - Sum each user vote or update general votes table?

Each user can vote once per item (only registered users can vote). So I have a user-votes table that include the user ID, voted Item ID and the vote value (from 1 to 10).
I need to show the total votes and rating for each item so I want to know what is best: Get from the user_votes table all the votes for that item OR save the vote each time a user votes in a general votes table and then get just that field form that database?

A:

If you just increment a sum you won't be able to prevent repeat votes from the same user.
You could use a combination of both.  Keep a table listing all of the votes and the user_id/ip address to verify that they haven't voted already and keep a sum associated with the item to avoid having to query the votes table.

