Think of the following sutation:

Comment ID 1
|
|--- Comment ID 2 (reply to ID 1)
     |
     |--- Comment ID 3 (reply to ID 2)
     |
     |--- Comment ID 4 (reply to ID 2)
          |
          |--- Comment ID 5 (reply to ID 4)

(example in action)

How do you keep above into SQL to ensure that I'm able to retrieve and list it later?

I am relatively good in PHP/SQL, but this case is recursively killing my mind. Any ideas?

You can store your computer data like a nested set. This is a type of method to represent tree-like data inside a SQL table.

It appears such as this is about data modling rather that php or mysql.

You can represent this right into a tree structure. Imagine that the comment just will need a parent or gaurdian. Each comment, one parent. Nevertheless the first item within the tree (the main element) will not possess a parent)

So, to model this in OOP you would employ a category Comment which will have itself associtated and also the title of this relationship is going to be is_child_of. One of these might have a null value. If you wish to obtain a step further into this solution look into the Composite pattern )

Concerning the database model, you simply need a table Comments which will have anything you need about the subject along with a area known as is_child_of. So each comment may have a parent but every discuss the greatest degree of the tree.

As comments come with an order, (inside your example it can't function as the same to swap comments 3 and 4) you need to consider that you may have to sort them in some manner (ID if it's an incremental value or perhaps a datetime).

Hope that can help :)