How do you store your data in the database

Discussion in 'MySQL' started by ketting00, Aug 2, 2011.

  1. #1
    Hi,

    I'm encountering a serious problem, at least for me, whether which the method should I use.

    Say, I have a user login system website that allows members to leave comment on their friends' profile and photo.
    The question is, should I store comment content separately between profile comment and photo comment, or should I store them together in a pool table.

    As in a trail phase, daily user comment is very huge volume for both kind of them.

    In the long run, which method is the best. I have no idea about this because it's is my first website of a kind.

    Thanks
    Ket
     
    ketting00, Aug 2, 2011 IP
  2. lithicstudios

    lithicstudios Peon

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I would keep all comments in one table. All you would need to do then is have a column for each id type (profile_id, photo_id). If the comment is for a photo (whos id is 1000) then profile_id=null and photo_id=1000.

    To get all the comments for the photo 1000, you would just query the comments table where photo_id=1000. Piece of cake! 
     
    lithicstudios, Aug 5, 2011 IP
  3. manjifera

    manjifera Well-Known Member

    Messages:
    232
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    118
    #3
    well if you keep comments seperate its good for management.. if you cant keep them then make two more fileds.

    cmm_type 1 for photo 2 for profile.
    and then UID for that photo or post.

    while fetching fetch it as ...

    select * from comments where uid=' UID_here' and cmm_type = '1' limit 0,100;

    correct my sql query as i am writing for your info...
     
    manjifera, Aug 6, 2011 IP