It all depends on how you want the ratings to work, who gets to up-vote or down-vote, whether you track everyone that votes to keep from having multiple votes from the same person, etc.
This is what I would do: add a unique numeric (long?) RatingID
field for each vote, link the PostID
field to the Comments table, add a Rating
(integer) field that is limited to values from 0 to 5 (or whatever range you prefer), and then calculate the average from all votes cast (delete the Rating_Count
and Average_Rating
fields). You could define a view to calculate the average ratings for each post to use for your routine for determining how to display it next to the Post.
Also, I would use an ID for each user, not use their names.
So my table would look like this:
RatingID, PostID, UserID, Rating
Also, to keep users from voting multiple times, the table would not allow multiple entries for the same PostID
and UserID
.