How is the database of Q & A website designed?

for example, like the Q & An on this site, what is the relationship between the structure of the data table?

user list-> question table, one-to-many
question table-> answer table, one-to-many
answer table-> comment form, one-to-many
comment table-> reply table, one-to-many

question
1. Is this the relationship between the tables above?
2. For the reply form, if you reply to me, I reply to you, and other users can also reply, how should the fields of the reply table be designed?
3, performance issues. Suppose there are a total of 100000 questions with 5 answers for each question, 5 comments for each answer and 5 responses for each comment, then the reply table has a total of 10 5 5 reply 5 = 12.5 million data. When you click from the question list page to enter the question details page, how to optimize the performance of so many layers of associated queries?

Mar.06,2021

take a look at this, the open source question answering system:

http://askbot.org/

https://github.com/erichegt/a.


  1. users and problem lists are not difficult to design. Each question has a user ID.
  2. it's not difficult to have a user ID and a question ID for each answer.
  3. comments should be separated from those of the question or the answer (or not, according to type, but it is strongly recommended that it be separated, with a single responsibility)

question comments are questions ID, commentators ID, superior comments ID (you reply me in your case). The answer comments are similar to

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9f235-47807.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9f235-47807.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?