I am building a small discussion board in my application. I have a table called 'Message' wherein i am storing the discussions...
Well, my case is :
a post can hav many replies and for each reply there can be a comment or reply.
Lets say
- A starts the thread.
B replies to A.- C comment on B.
D also comment on B.
F replies to A.- G replies to F.
- C comment on B.
My structure of 'Message' table is:
PostID tinyint(11) unsigned auto_increment
Message varchar(255)
PostedBy varchar(15)
ParentID tinyint(11) unsigned
BranchTutorID tinyint(11) unsigned
DatePosted datetime
Status char(1)
Unit tinyint(3) unsigned
currently what i am storing is..consdering the above example...
the first record in message table will be (i am writing only few column values which is imp..considering all users are from same unit)
PostID PostedBy ParentID Unit
First Record 1 A 0 1
Second Record 2 B 1 1
Third Record 3 C 2 1
Fourth Record 4 D 2 1
in the above records, ParentID '0' means its new thread...ParentID=1 means this post is a reply/comment for the PostID 1 and so on...
i want to display the whole discussion messages for a particular unit...
i am struck in that..
currently i am using ParentID to denote for which post the reply is...
I am using PHP 4.1/MySQL 3.23
I don't know whether the table design is correct or not...
Could you please suggest me how to accomplish this...
Please help me..
Thanks in advance...
Shankar