Best Practices for NoSQL/Cosmos DB Data Models

Stinnett-Christy, Dell 6 Reputation points
2021-04-28T22:17:29.163+00:00

I'm considering recommending Azure Cosmos DB or another NoSQL database for a project I'm currently blueprinting. However, all of my experience has been with traditional relational databases.

This particular project is about building a centralized benchmark repository across a number of topics and sources, with multiple benchmarks expected for each topic. The main purpose is to provide data for analytics, including some predictive analytics. It will be developed in phases, with each phase potentially requiring schema changes. Data will be pulled in from multiple sources and very little will be manually entered.

The reason I'm considering NoSQL instead of a relational database is the amount of schema changes that I suspect as the project moves through its phases and because of the ease of getting data for analytics.

I know the basic schema I would use for a relational database, including "lookup" tables that will ensure data consistency for analysis and reporting. However, I'm not completely sure how I would model that for a NoSQL database, especially what would be the lookup tables.

Does anyone have any recommendations around best practices for building this type of model for a NoSQL database?

Thanks!

-Dell

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,901 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Mark Brown - MSFT 2,771 Reputation points Microsoft Employee
    2021-04-29T00:21:59.913+00:00

    This is a very broad question and there are multiple approaches you can take and typically comes down to cost as well as performance (latency).

    One approach you may to try is to create a single container and put all of your lookup data within it and use a partition key for the "type" of data it is. This way a query for that data will always be within a single logical partition.

    However, I would also suggest that with lookup data you may want to persist that data into the container you are looking it up for. For instance if you have a products container you should include both a product category id and the product category name in the product container so that you do not have to look it up every single time.

    There is some good content I strongly encourage you to consume before you get to far designing a model for this type of database. It will save you countless hours or days of work and pain.

    Video: Data modeling and partitioning in Azure Cosmos DB: What every relational database user needs to know
    GitHub Repo for that talk: https://github.com/AzureCosmosDB/CosmicWorks
    Doc: https://learn.microsoft.com/en-us/azure/cosmos-db/modeling-data
    Doc: https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-model-partition-example

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.