Azure Cosmos DB is a multi-model database that supports various data models, such as documents, key-value, graph, and column-family3. The core content-model of Cosmos DB’s database engine is based on atom-record-sequence (ARS), which allows it to store and query different types of data in a flexible and efficient way3.
To optimize the data store for reading data, you should consider the following factors:
The size and shape of your data
The frequency and complexity of your queries
The latency and throughput requirements of your application
The trade-offs between storage efficiency and query performance
Based on these factors, one possible design that you could implement is B. In a company container, create a document for each company. Embed the users into company documents. Use the company ID as the partition key.
This design has the following advantages:
It stores companiesand users as self-contained documents that can be easily retrieved by company ID1.
It avoids storing redundant data or creating additional containers for users1.
It allows you to browse by company and browse the users by company with simple queries1.
It shows a details page for the company and all the related users by fetching a single document1.
It leverages the benefitsof embedding data, such as reducing the number of requests, improving query performance, and simplifying data consistency2.
This design also has some limitations, such as:
It may not be suitable for some users who have data that is greater than 2 KB, as it could exceed the maximum document size limit of 2 MB2.
It may not be optimal forscenarios where users need to be associated with more than one company or queried independently from companies2.
It may not be scalable for companies that have more than 1,000 users, as it couldresult in hot partitions or throttling2.
Depending on your specific use case and requirements, you may need to adjust this design or choose a different one. For example, you could use a hybrid data model that combines embedding and referencing data2, or you could use a graph data model that expresses entities and relationships as vertices and edges.