Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Unanswered: help in designing MySQL table

    Hi, Its manis I am trying to make a website like http://hi5.com.I am not getting the best design for designig the table to store the information of the user and his friends.I need a table to store the information of the user and the other members who are his friends.I need the porvision to add the new friends. But I am having problem in designing the appropriate table for this case.Please help me out

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what have you got so far?
    what problems are you hitting?
    do you think your data model is appropriate for what you want to do?
    it will help if you could get your data model into a ERD format, but if the worst comes to the worst a brief layout identifying just the keys (pk & fk's) would be useful.

  3. #3
    Join Date
    Feb 2008
    Posts
    2

    data model

    Quote Originally Posted by healdem
    what have you got so far?
    what problems are you hitting?
    do you think your data model is appropriate for what you want to do?
    it will help if you could get your data model into a ERD format, but if the worst comes to the worst a brief layout identifying just the keys (pk & fk's) would be useful.

    I am wandering how to store the information about the friends that have been added.
    The case is that One table contains the information about the user along with the key.But the user may have many friends and those friends have that user as a friend too.


    Fristly I planned to design a table that contains the userid,username, and poassword .Another table containing the user information and then I stuck when I had to record his friends...

    So I am confused how to design a good table for this case.
    Please help me out...

  4. #4
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    Probably a question better suited to the database design section of this forum.
    Nevertheless.

    It seems apparent that you should need a users table (as you have already)
    and another table to provide mapping between users.

    e.g.
    Code:
    users:
    
    id | name | email
    ===|==============
    1  | joe  | joe@joe.com
    2  | fred | fred@fred.com
    
    friends_mapping:
    
    user_id | friend_id
    ========|==========
    1       | 2
    2       | 1
    Note in the above that the relationship is a two way process.
    i.e. joe might consider fred to be a friend (hence row 1)
    but in order for this to be a two way relationship fred must consider joe to be a friend (hence row 2)

Posting Permissions

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