When do I need to create a new Collection?

In Relational Databases, it is necessary to create multiple tables to have a healthy system with good data normalization, so that at the end of the day, the database has 5 related tables, for example. However, in MongoDB, it is possible to consolidate all 5 tables into a single Collection.

So, the question remains:
When should I create a new Collection?

Hey @Gabriel_Pavao,

Welcome to the MongoDB Community forums :sparkles:

In MongoDB, collections are used to group related documents and provide an organized structure for storing data. It is recommended to create a new collection when there is a logical separation or when the data in the collection has a different structure or purpose. Doing so allows us to maintain data organization and improves query performance.

When considering whether to create a new collection, think about the distinct characteristics or access patterns of the data. For example, if you have an e-commerce application that stores information about both products and customers. In this case, you might create separate collections for “products” and “customers” to maintain the different attributes and relationships associated with each entity.

On the other hand, if a customer has multiple shipping addresses, you can choose to embed the shipping addresses as an array within the “customer” document. This avoids the need to create a separate “shipping addresses” collection.

Also if you’re starting your MongoDB journey, I would recommend the following resources:

These resources will provide you with valuable insights for designing effective MongoDB schemas.

Best regards,
Kushagra

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.