...

View Full Version : rating system



RikoGuy
02-01-2007, 12:48 AM
hello

i want to do a rating system like youtube's where it averages out the total ratings. i'd store each of the ratings per each row and have them seperated by comma's then in my code put them in to an array.

i also wanted to store the usernames of the voters in the database in the same fashion (without displaying them though) as above say instead of using cookies (as they can be deleted). would method this be feasible? or would this say overload the database and cause slow down?

thanks!

eric sullivan

guelphdad
02-01-2007, 05:40 AM
that is a very poor database design. you need three tables

1) a user table with an id for the user and other info about the user
2) an object table with an id for the object being voted on and other info about the object
3) a voting table with three fields userid, objectid, vote

you would add a new row in the third table every single time an object is voted on. Video "A" gets 100 votes, then it has 100 rows in that table.

Do not store comma separated values in a database, there are too many problems inherent in getting your data tabulated and you are violating 1st normal form of database normalization.

StupidRalph
02-02-2007, 10:30 PM
Do not store comma separated values in a database, there are too many problems inherent in getting your data tabulated and you are violating 1st normal form of database normalization.

Are there any exceptions to this rule? Specifically, storing keywords for a row? I thought it would be easier this way since I was using a FULLTEXT index. But I have no problem changing it.

guelphdad
02-03-2007, 02:25 AM
Here (http://www.guelphdad.wefixtech.co.uk/sqlhelp/lists.shtml) is an article I have on avoiding lists, and why it is best practice to avoid using them.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum