[Monogdb] MongoDB's top 10 application design skills: monogdbmongodb

Source: Internet
Author: User

[Monogdb] MongoDB's top 10 application design skills: monogdbmongodb
Tip 1: a compromise between speed and integrity

Data used in multiple documents can be embedded (Anti-paradigm) or referenced (paradigm. This strategy has no advantages or disadvantages, and each has its own advantages and disadvantages. The key is to select a suitable application scenario. The de-normalization will produce inconsistent data. However, in the case of normalization, the application must perform an additional search at each validation. Because extremely high performance and instant consistency cannot both be achieved, you must know which one is the most needed for the application.

Considerations include:

Do you always need to read data that is hardly changed once?

Is consistency important?

Do you want to read it quickly?

Tip 2: to adapt to the future, data needs to be normalized to make data availability more persistent. In the future, data can be queried in different ways in different applications. The premise is that some data will be continuously obtained by various applications for a year.
Tip 3: Try to use a single query to obtain data. The mongodb database design should start with the query of application units. Application Unit: for web applications or mobile applications, a request to the backend can be regarded as an application unit for desktop applications. One user interaction can be regarded as an application unit for the analysis system, loading a chart is counted as an application unit technique. 4. Embedding associated data when you are hesitant between embedding and referencing documents, the purpose of the query is to obtain the field itself or to obtain more extensive information. If the former is recommended to embed associated data. Tip 5: Embed time point data. For example, if someone updates personal information, in this case, you do not need to change the previous order content skills. 6. Do not embed the increasing data into mongodb to store data, which determines that the continuous addition of data is very inefficient. In normal use, the data and object size should be relatively fixed. Tip 7: pre-fill data if you already know which fields will be used in the future, the first insertion will take these fields with higher efficiency than creating them when they are used. For example, if you want to use a new set every day, you 'd better create it in advance. Tip 8: Allocate space as much as possible. You can use this optimization method as long as you know that the document is relatively small and will be determined later. At the beginning, the file is inserted with the same size as the final data. Add a garbage field (which contains a string of the same size as the final size of the document) tip 9: Use arrays to store embedded data that requires anonymous access. A common problem is whether the embedded information is a piece of data or a document. If you know exactly the query content, use the sub-file. If you are not sure about the specific content of the query, you need an array. An array is usually used when you know the query conditions for some items. Tip 10: Document self-sufficiency

Mongodb is a brainless large data storage. Mongodb does almost no data processing and only stores data. We recommend that you keep this in mind to avoid mongodb performing computation on the client. Even if you write a small task, such as average or sum, you need to do it on the client.

If the information to be searched must be calculated and cannot be obtained directly from the document, there are two definitions:
High performance cost; optimized the document structure so that the information can be directly obtained from the document.








 



Related Article

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.