Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: rating system

  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • #3
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    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.

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Here is an article I have on avoiding lists, and why it is best practice to avoid using them.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •