Get startedGet started for free

When to use document databases

1. When to use document databases

In this lesson, we are going to learn when document databases are suitable and when not.

2. Suitable cases

Let's start with some scenarios where document databases are a good fit. The first use case we are going to present is the storage of catalogs. For instance, e-commerce websites and applications store catalogs of their product information. As we saw before, documents can be polymorphic, so document databases are helpful in this scenario because each product may have different attributes compared to other products. Besides, we can embed related information like the product category and retrieve all of this information with a single query.

3. Suitable cases

Applications may want to store the events that occur, such as the logging of a user, the purchase of a product, errors, etc. As the volume of events may be high, the sharding technique can be helpful. Events can be sharded by time, by the type of event, etc.

4. Suitable cases

Document databases also fit well for storing user profiles, as we saw in the example of Datazy. Users can add or remove information, so their profiles may vary over time. As documents are flexible in that way, document databases are a good choice for storing user profiles.

5. Suitable cases

The domain of content management systems, like blogs or video platforms is also suitable for document databases. The content that the users create such as comments, images, videos, etc., can be saved in document databases.

6. Suitable cases

Finally, document databases are a good option for storing data for real-time analytics. Many companies track real-time performance metrics such as page views, unique visitors, etc. Even if new metrics are needed, it will be very easy to add them.

7. Unsuitable cases

Document databases have evolved a lot in recent years, offering transactions, security controls, powerful query engines, etc. These features mean document databases are used in more cases than they used to. However, if we already have very structured data, document databases will not be the best solution. Also, if we want our data to always be consistent, we have to know that some document databases don't ensure consistency.

8. Let's practice!

Good job! Let's do some exercises to practice what we have learned!