Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2007, 12:48 AM   PM User | #1
RikoGuy
New to the CF scene

 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
RikoGuy is an unknown quantity at this point
rating system

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
RikoGuy is offline   Reply With Quote
Old 02-01-2007, 05:40 AM   PM User | #2
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Old 02-02-2007, 10:30 PM   PM User | #3
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
Quote:
Originally Posted by guelphdad View Post
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.
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.
StupidRalph is offline   Reply With Quote
Old 02-03-2007, 02:25 AM   PM User | #4
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
Here is an article I have on avoiding lists, and why it is best practice to avoid using them.
guelphdad is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:16 PM.


Advertisement
Log in to turn off these ads.