Rating system sql code
View Single Post
11-10-2008, 01:17 AM
Join Date: Sep 2007
Originally Posted by
Hm, ye okey. Your idea is good, but say you have 1000 users, and everyone rates everyone, then you'd have 1000*1000 entries in your ratings db, which is.. quite alot. If you would do it my way, you would just have 1000 entries in the db, and all the ratings could be counted quite easy, while it's really simple to calculate the avarage ratings that someone has got
It would only be a million rows, which would not be terrible if you had that much traffic. But you would have to update ratings every so often to a smaller table and stuff like that. There would be so simple way to make a script for a site like that. I'm not going to get into large database stuff right now since I don't have a ton of experience with it.
While you could not keep records of who rated who (meaning one person could rate someone to whatever they wanted), you could have it keep adding the numbers (a 5 and a 2 would make the value 7) and divide it by the number of ratings given.
So you would have on your users table:
Then keep adding rating by each number given and increment rater_count by one. Dividing the two would give you the average.
View Public Profile
Send a private message to Village Idiot
Find More Posts by Village Idiot