I want to be a question-and-answer website, asking a question about the design of a table, a question and some of the answers below. Do you want to use a table?

  mysql, question

For example, for a question-and-answer website such as segmentfault, a new question will have a question ID, then a question can be answered by everyone, and each answer can be answered by everyone’s comments.

How does a structure like this build a watch?

Question list,Answer sheet,Comments formIs that so?

Or just one table can be used to solve the problem, and a pid field is used to represent the relationship between each record (we regard questions, answers, and comments as one record at a time). For example, a pid of 0 indicates that this is a complete problem, and is directly subordinate to the record of the problem. The record with pid as the id of the problem is the following answer. According to this relationship, they can be related. However, it feels so complicated that I don’t know if it is feasible.

This is similar to the model of Baidu Tieba. Posting, follow-up, comment, reply, DZ is the same. I don’t know how to design DZ’s watch structure. Is there anyone familiar with it who can give me some advice?

Thank you!

There are many existing open-source model of this type, and the data structure is quite mature. You can find one and install it, and you can know its data structure and even its programs.

For example, the following systems

In the early days, if we had studied open-source model more, we would not have taken a detour.