FAQs about database design, such as the number of replies and list pages

Source: Internet
Author: User
I want to create a blog with several common database design questions, such as the number of replies and list pages. the brief requirements are as follows: the number of comments should be displayed on the Article (Article) list page, the article list should be displayed by page, and the comments list should also be displayed by page (the Comment list should be displayed by ajax page ). Because I have not done many projects, I would like to ask a few questions: 1. some common database design questions, such as the number of replies and list pages.
When I create a blog, my brief requirements are as follows: the number of comments to be displayed on the Article (Article) list page, the Article list to be displayed by page, and the Comment (Comment) the list must also be displayed by page (the comment list is displayed by ajax page ).

I would like to ask a few questions about how many projects I have never done:

1. is the number of comments generally used as a field in the article table or is it implemented through select count during execution? If select count is used, if N articles are displayed in the article list each time, will the performance be degraded if N select count is executed to query the number of replies?

2. assume that the blog homepage contains a list of many articles (such as weekly rankings, daily rankings, recent click rankings, related articles, latest articles, and latest comments ), besides caching part of list blocks (such as the weekly and daily rankings that are rarely updated, A single http request has 10 select statements (all the select statements have been optimized). isn't that too much?
------ Best solution --------------------
1. one field should be used for storage.
2. in principle, the query should be minimized. However, if your blog has a low access volume, this is nothing.
------ Other solutions --------------------
One field should be used for storage, but it is best to re-count the number of initialization programs, otherwise there may be errors after a long time.

If you do not want to store fields, you can use the cache.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.