Get the App
SLTechnology News&Howtos  ›  Database  › 

50 suggestions for MongoDB developers Tip13

Shulou Source: shulou.com Published: 2022-06-01 17:00:31 10月03日 Update

This series of articles are translated from "50 Tips and Tricks for MongoDB Developers". I can't find the Chinese version for the time being. Anyway, I have been studying mongodb deeply recently, so I just want to translate it. On the one hand, enhance the effect of our own learning, on the other hand, let the big family to experience what we mongodb users need to pay attention to.

First of all, I declare that my English level is not too high, and some English translation into Chinese can not find suitable words to express, so the original English words may appear in the article, or the translation in some places will be a little blunt, that is to say, there will be literal translation. The main purpose of translating this book is for everyone to learn and explore. If there is any inaccuracy in translation, or if there is a more accurate translation, please point out that I will correct it in time. Thank you in advance.

Tip#13.Write code to handle data integrity issue

Solve the problem of data integrity with code

Considering the inherent non-structural nature of mongodb and the advantages of embedded structure, you need to ensure data consistency in your application.

Data inconsistencies can cause problems with the system.

Tip#1.Duplicate data for speed,reference data for integrity (data redundancy is for performance, and referencing data is for integrity.)

Tip10.Design documents to be self-sufficient (designing documents to be self-sufficient)

If you listen to the above two suggestions, there will be data inconsistencies. For these types of inconsistencies, you need to write some scripts to check your data.

If you use some of the previous suggestions, depending on your application, you may need to match some batch jobs. For example:

Consistency check, check calculated values and duplicate data, so that everyone has a consistent value. Pre-populate and create some documents you will need in the future. Aggregator, keep updating your aggregation values.

Some other scripts that may be required.

The structure Checker checks whether your document contains specific fields, or even modifies those fields that are in question, or notifies you that there is an incorrect document. Backup jobs, forced data synchronization, locks, backup databases and other scheduled jobs.

Run these jobs in the background to protect your data.

Tags: Data consistency place document assignment check structure problem English Learning suggestion Precision consistency backup Field Integrity article script Chinese Application Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Tech Info Redmi vpn OPPO Reno