SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm hoping somebody here can give me some advice with this, but here goes.

    I've got a jokes and humor website which I'm in the process of porting it over to a MySQL database. I'd like to include a feature whereby my users can rate the jokes and the ratings would be averaged out and displayed.

    Now, my problem is that it sounds, to me at least, that this approach would be rather server taxing. I'd have to store every rating entered and average them out every time someone wanted to see the average rating.

    Anybody have any other thoughts about how I could do this? I know this sort of thing has been done before, so if anybody has any thoughts, I'd really appreciate it.

    Thanks a lot!

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nothing comes to mind...server strain sounds inevitable for a site like this...perhaps you could have one database for the ratings and another that holds the average, or something along those lines, so you'd only have to access the one database, rather than calculate the average everytime...am I making sense?


    ------------------
    Chris Bowyer chris@mycoding.com
    MyCoding.com: Visit for Launch Notification!
    DomainMailings.com: Who Says All The Good Ones Are Taken?
    MovieForums.com: Talk About Your Favorite Flicks!

  3. #3
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to figure out a solution for this for my site as well. Using a seperate table for the average rating would require a field for the total number of votes as well, in order to allow the averaging. Most likely, you'd need to store the individual ratings as well, to show who rated what. It gets pretty complicated doing it this way.

  4. #4
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What if you had your table with all the user ratings as well as a rating field in your jokes table. When somone submitted a rating, your site would calculate the new average rating for the joke and store it in the average rating field of your jokes table. When the jokes are displayed a precomputed rating would already be available.

  5. #5
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That last post was a little unclear. Lets see if I can explain it better this time.

    Lets say you have two tables:
    Jokes
    with a "Joke Rating" field in addtion to your other fields.
    Ratings
    with each individual rating.

    Someone wants to rate your "Why did the chicken cross..." joke, so they fill in the form and submit. Now your program saves that rating in the ratings table. Then it caculates a new average rating for "Why did the chicken cross..." and stores it in the jokes table.

    Whenever a user wants to view your jokes, you already have a rating for each one! No averageing a rating for each one for each viewing.

    Since it computes this average rating every time a new rating is added, the average rating always remains current.


    [This message has been edited by MAC (edited August 17, 2000).]

  6. #6
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestion, Mac. I'll definetly toy around with it some and see what I can do with it.

    -Alex
    webmaster@stupidity.org

  7. #7
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your welcome

    Let me know how it works. And if you find anything that works better tell us


Bookmarks

Posting Permissions

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