Answer the question
In order to leave comments, you need to log in
What is the best way to store a comment-review table in MySQL?
Good day of the day.
I am writing a small CMS in which it will be possible to leave reviews, questions, answers on the product.
It is assumed that the functionality:
- The comments feed inside the product can contain both reviews and questions (they go in one list in chronology);
- Also, for each review or question , there can be a branch of answers (everything is displayed under the parent review / question, in chronological order);
- All three feedback / question / answer contain a "text" field (up to 3000 characters);
- while only have a reviewthere are additional fields: "product evaluation"; "time of use of goods"; "merits" (up to 3000 characters); "disadvantages" (up to 3000 characters)
Initially, I did everything in one table, but now I began to be embarrassed that in the case of storing records in the database as a question / answer , empty fields "walk" ("product evaluation"; "time of using the product"; "merits" " ; "limitations"). It is expected that there will be more answers / questions than reviews
Question: Is it worth splitting the table into two, ie. take out fields that relate only to the review ("product evaluation"; "time of use of the product"; "advantages"; "disadvantages"
Answer the question
In order to leave comments, you need to log in
Definitely worth it.
Common practice for a table architecture with a lot of options:
The more concise and smaller the table structure, the better.
I agree that it is better to move the binding to a separate table, store the general data in the first one, and move the data for a separate task to a separate table, this will allow you to separate the logic and support the application in the future. For example, add an assessment to the comments, also put it in a separate table, in other words, you can build up the application logic and at the same time do not run it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question