Azure Cosmos DB is a multi-model databas e that supports various data models, such as documents, key-value, graph, and column -family 3 . 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 efficien t way 3 .
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 companies and users as self-contained documents that can be easily retrieved by company ID 1 .
It avoids storing redundant data or creat ing additional containers for users 1 .
It allows you to browse b y company and browse the users by company with simple queries 1 .
It shows a details page for the company and all the related users by fetching a single document 1 .
It leverages the benefits of embedding data, such as reducing the number of requests , improving query performance, and simplifying data consistency 2 .
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 exc eed the maximum document size limit of 2 MB 2 .
It may not be optimal for scenarios where users need to be associated with more than one company or queried independently from companies 2 .
It may not be scalable for companies that have more than 1,000 users, as it could result in hot partitions or throttling 2 .
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 data 2 , or you could use a graph data model that expresses entities and relationships as vertices and edges.