SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Parent Child Join

    Hi,

    I want to implement Youtube like "comment system". For example:

    1.Comment

    15.Comment(replied to 1.comment)

    21.Comment(replied to 1.comment)

    2.Comment
    3.Comment

    99.Comment(replied to 3.comment)

    ...

    comments
    c_id c_text
    1 1.comment
    2 2.comment

    comment_replies
    c_to c_from
    1 15
    1 21
    3 99

    Select * from
    comments as c
    join comment_replies as r on c.c_id = r.c_to
    join comments as c2 on c2.c_id = r.c_from

    Am i doing it right? How can i prevent parent record repetition?

    Thanks.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,151
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    You could really just use one table for all this and save yourself the trouble.

    - comments
    -- id
    -- reply_id (references comments(id))
    -- user_id (references users(id))
    -- message
    -- created

    Maybe there is something I'm misunderstanding…


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
  •