用于对话的数据库逻辑(如论坛)PHP,MySql

I want create a page where is possible create topics and users are able to comment.

I create the table discussion with a recursive relation. I don't if the idea is good.

How can I find the id of the parent when a user comment? I don't if is clear...

Below you will find 3 screenshots to explain you better the situation.

enter image description here

enter image description here

I would not have the parentID point to the comment that precedes it, that's bad practice all around. The parentID should point to the topic and then when selecting all comments from the database, make a query that orders them by time or their ID to see what order they were posted in.

For example...

SELECT * FROM `discussion` WHERE `parentID` = 1 ORDER BY `time` DESC;

The parentID should be null for topics and not null (integer) for replies (the integer should point to the ID of the topic). I hope I understood what you were asking correctly.