mysql database design: threads and replies
- by ajsie
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?