Multiple arrays in MySQL

Discussion in 'MySQL' started by gbh, Sep 20, 2008.

  1. #1
    How would I do the following?

    Members of a site can say what movies they like, and I want to link a particular movie with a member. However, many members could like that same movie, so I don't know what layout I must have to be efficient...

    Possibility 1)

    User-------Movie_1-------Movie_2-----Movie_3--------------Movie_4
    bob--------wanted--------taken-------finding_nemo---------etc
    cindy------taken----------family_guy---wanted--------------etc

    Possibility 2)

    Movie-----------User_1------User_2----etc
    Spiderman-------fred--------lolcat------etc
    Taken-----------bob--------cindy


    I need to be able to pull from the DB all the movies a user likes, but also, I need to be able to see what movies people like in common.. like cindy and bob both like Wanted

    Thanks in advance!
     
    gbh, Sep 20, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Make 3 tables

    1. Users (User id, User)
    2. Movies (Movie ID, Movie Name)
    3. User_Movies (User Id, Movid Id)

    User_Movies table will have the user id and the id of the movie he/she likes.
     
    mwasif, Sep 20, 2008 IP
  3. gbh

    gbh Member

    Messages:
    78
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    48
    #3
    Thank you mwasif, I think that may be the best option..
     
    gbh, Sep 20, 2008 IP