Video Transcript (English)
Congratulations! You have now completed this unit on Schema Design anti-patterns.
In this unit, we covered the most common schema design anti-patterns that developers encounter, and some of the solutions that you can use to address them.
We started with the unbounded arrays anti-pattern, which occurs when a document contains a large, growing array with an unlimited number of elements.
We covered two possible solutions: One applying the subset pattern to separate the array into a new collection, including a subset of the documents in the main document. And two applying the extended reference pattern to separate data into two collections and referencing the relationship.
Next, we looked at the bloated documents anti-pattern.
We encounter this anti-pattern when we store related data together that is accessed separately by our application.
You learned that we can identify this problem by reviewing the system resources and estimating our working set size.
We fixed it by updating our data model to reduce document size and improve performance.
Then, you learned how to identify the massive number of collections anti-pattern.
This usually happens when we have more than ten thousand collections per replica set.
You learned that updating the schema design can help reorganize your data and decrease the number of collections in your database.
You also learned that in some cases sharding your database could be a good solution to handle large numbers of collections.
Then, we looked at the unnecessary index anti-pattern, and how this can happen when we create indexes that are either redundant or rarely used.
These can take up space and impact performance without any benefits.
We showed you how to identify and remove unnecessary indexes.
Next, you learned about the data normalization anti-pattern, which happens when we separate data that is frequently accessed together.
We showed you how to fix this using the subset pattern and the extended reference pattern.
But remember that the best solution will depend on your data and the needs of your application.
Finally, you learned how to identify the case sensitivity anti-pattern.
This happens when using the default MongoDB query settings but expecting search terms to ignore case.
You learned how to spot three different ways that this anti-pattern can show up in an application and what you can do to fix each one.
Remember, case-insensitive queries must be supported by case-insensitive indexes.
Also, queries and indexes must use the same collation to provide the expected results.
And finally, the collation strength should be 1 or 2.
Even if you follow best practices, you may encounter one of these anti-patterns. Luckily, now you have the tools you need to get back on track.
Now that you understand these anti-patterns, you can keep them in mind while you’re planning your schema and thinking about how you should model your data.
If you'd like to learn more, you can review MongoDB’s documentation and check out the other patterns in the MongoDB blog series “MongoDB Schema Design Anti-Patterns”.
We hope you enjoyed this unit on anti-patterns. Never stop learning!