When you have many documents mostly with the same properties, but they also have their specific attributes, this pattern can be useful for you. All you need to do is create one array property for all these characteristics and put them into as key-value objects. This solution will enable you to sort and search documents in an easier way and it will improve the performance. You can use it, eg., in an e-commerce project where you have a lot of similar products.
This kind of pattern, as the name suggests, makes a tree of dependencies between documents of a collection. There are several approaches to make a tree, but the easiest is to add properties with references to a parent and children of a document. This design pattern will be useful everywhere where there is a hierarchical data structure, eg., dependencies between employees in an organization.
Extended Reference Pattern
Last but not least, the design pattern can improve the performance of your application if you often make JOIN operations on your documents. To reduce them, you need to embed the most necessary properties of a document of the second collection into a document of the first one. In this way, you won't have to make JOIN operations so often, and if you need more properties of the document of the second collection, you always have access to take them. It can be useful also, eg., for e-commerce projects.
To sum up, these three patterns, I described shortly, can improve the organization of your data structure and optimize the performance of your application. I encourage you to read the MongoDB documentation to get to know more. If you want to explore more design patterns, I recommend you to join the data modeling course on MongoDB university.
Read more from our brave's writers
Bravelab.io is recognized as a top Custom Software Developer by Clutch
In 2020, more companies are realizing the benefits of custom software development. It helps address specific issues and can be much more efficient than out-of-the-box software. We’re excited to be a part of this growing industry.
Bravely App - How to be more productive with Django, quick
We wanted to automate some of the internal processes and store different data in one place. The idea was to create a simple tool that would assist our employees with their operational tasks. The main goal was to build and deliver the solution quickly, without unnecessary fireworks.
Recruitment system - integrating Gmail, Bravely, Jira, Slack, and Copper CRM
The recruitment process is complex and consists of many steps. In our system, new candidates can apply for a job position through: various external sites, dedicated email addresses, the form on our website, or any other available way. Acquiring candidates from many sources is problematic and time-consuming. Creating one aggregated email address solves only part of the problem,especially if it aggregates other things as well, for example, notifications. Therefore, it is important to create a system that can improve effectiveness and shorten the time needed to manage the application process.