There really is no "best way," there are hundreds of ways. If it's an existing system, build it on what's been started, otherwise, some ideas. I'll start with this one:
How can i store data in order to know what message is a reply?
Fairly easy, and gets important when you go to move or delete stuff.
id|thread_id|post_id|reply_to|userid|content|post_time
So if it's a reply you might have
1234|4567|4566346|
4568|56547|Bleah|2010-026-10 12:37:34
A reply just to a thread, or the original post:
1234|4567|4566346|
0|56547|Bleah too|2010-026-10 12:18:34
The ordering by date would take care of where they fall, but you would use the reply_to value to determine any visual indenting, etc.
select * from posts where thread_id=4567 order by post_time asc;
Then comes pagination, user preferences (examples, thread view, sort in direction, make user "annoying" invisible), admin preferences/banning, templating, avatars, signatures . . . . you sure you want to tackle this? :-)