I have been blogging for myself recently. Function of the article. The user clicks the article id to go to the detailed article content display page and the user comment content corresponding to the current article. The following are my ideas. I do not know whether there is any deficiency. I hope you can give me some advice. Thank you. 1. article table 2. user table (nothing...
I have been blogging for myself recently. Function of the article. The user clicks the article id to go to the detailed article content display page and the user comment content corresponding to the current article. The following are my ideas. I do not know whether there is any deficiency. I hope you can give me some advice. Thank you.
1. document table
2. user table (no problem, no texture)
3. user comment table
4. thinkphp gets a single article and displays the comment content code
5. front-end display
Question 1: when obtaining a single article. Whether the comment content corresponding to the current article is queried in an SQL statement, and then the comment content is paginated.
Question 2: The above 3rd. when a user reviews an article multiple times. All the data found here is repeated. Because I uniformly query by document id.
To sum up: is there a problem with my table design. Whether the SQL query is also faulty.
Thank you for your advice.
Reply content:
I have been blogging for myself recently. Function of the article. The user clicks the article id to go to the detailed article content display page and the user comment content corresponding to the current article. The following are my ideas. I do not know whether there is any deficiency. I hope you can give me some advice. Thank you.
1. document table
2. user table (no problem, no texture)
3. user comment table
4. thinkphp gets a single article and displays the comment content code
5. front-end display
Question 1: when obtaining a single article. Whether the comment content corresponding to the current article is queried in an SQL statement, and then the comment content is paginated.
Question 2: The above 3rd. when a user reviews an article multiple times. All the data found here is repeated. Because I uniformly query by document id.
To sum up: is there a problem with my table design. Whether the SQL query is also faulty.
Thank you for your advice.
No problem in table design. SQL error
According to your statement, it is wrong because comments are one-to-many. to display all comments, multiple tables must be left-connected as the master table.
However, although this can be written, it is not recommended, because the article simply queries it, the comment is queried based on the id, there is no need to go to the left, the time of two queries, it is faster than the time above, so there is no need to write that.
SQL statement: 1. query article content 2: query comments, limit, then comment on the left-side user table of the table, condition article id
The article content and comment list are separated for query. The more functions a SQL statement has, the more troublesome it will be to be changed later.