SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    0 Post(s)
    0 Thread(s)

    Rating system, best solution?

    This thread got me thinking of a new solution for my rating-script.

    As of now it's like this, I have one table where I store the score, total rates and what movie was rated, I also have an extra table where I store the user id and the movie id to keep track of which users have rated the particular movie(s).

    This works fine and all but would this solution be better:

    Add and extra column to my "main" table, let's name it "raters", and when a user rates a movie I insert their username or id there.
    I would then use explode to get the users and see if they had rated the movie.

    What would be better performance wise? Let's say we are dealing with 50.000 users (not the case) What is better, Have 50.000 rows in the keep-track-table or have 50.000 users(a lot of text/numbers ex: 1|2|412|2837918|1212) in the extra field "raters"?

    Hope I explained good enough - Online Comic!

  2. #2
    SitePoint Addict jkassemi's Avatar
    Join Date
    Jan 2005
    0 Post(s)
    0 Thread(s)
    Just a hunch, but I'd expect the method without explode would be faster... If anything, it offers you a little more control...

    Think about exploding a string into a 50000 unit long array, and then sorting through the information to determine who reviewed it... that'd be one heck of a process... I'd set up something like this:

    table 1:
    movie_id (unique) | movie_name | movie_synopsis | movie_stars | movie_etc

    table 2:
    movie_id (repeated for each review) | individual_score | scored_by_user

    Then you can perform the calculations on the movie's score every time somebody wants to see it... mysql will cache the results so you don't have to worry about your computer performing the same calculation again and again...

    It seems a little easier way of organizing and maintaining the information...
    And on top of that, you can add a "review" column or something to the end of table2, allowing users to make quick comments regarding a movie..

    Hope this helps,


Posting Permissions

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