mysql database design: thread and reply of a reply?

Posted by ajsie on Stack Overflow See other posts from Stack Overflow or by ajsie
Published on 2010-04-18T22:20:21Z Indexed on 2010/04/18 22:33 UTC
Read the original article Hit count: 213

Filed under:
|

in my forum i have threads and replies.

one thread has multiple replies. but then, a reply can be a reply of an reply (like google wave). because of that a reply has to have a column "reply_id" so it can point to the parent reply. but then, the "top-level" replies (the replies directly under the thread) will have no parent reply.

so how can i fix this? how should the columns be in the reply table (and thread table).

at the moment it looks like this:

threads: id title body

replies: id thread_id (all replies will belong to a thread) reply_id (here lies the problem. the top-level replies wont have a parent reply) body

what could a smart design look like to enable reply a reply?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database