DP-420 practice question 12 of 25

You need to create a data store for a directory of small and medium-sized businesses (SMBs). The data store must meet the following requirements: *…

Full set: 144 questions
You need to create a data store for a directory of small and medium-sized businesses (SMBs). The data store must meet the following requirements: * Store companies and the users employed by them. Each company will have less than 1,000 users. * Some users have data that is greater than 2 KB. * Associate each user to only one company. * Provide the ability to browse by company. * Provide the ability to browse the users by company. * Whenever a company or user profile is selected, show a details page for the company and all the related users. * Be optimized for reading data. Which design should you implement to optimize the data store for reading data?
Answer options
A: In a directory container, create a document for each company and a document for each user. Use company ID as the partition key.
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. Correct answer
C: Create a user container that uses the user ID as the partition key and a company container that container that uses the company ID as the partition key. Add the company ID to each user documents.
D: In a user container, create a document for each user. Embed the company into each user document. Use the user ID as the partition key.
Correct Answer:
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.
Explanation

A bounded one-to-many relationship (each company ≤1,000 users) that is always read together is best modeled by embedding the child entities inside the parent document. By storing one document per company and embedding the array of user objects, a single point-read (partition key = companyId, id = companyId) returns both the company profile and its users, satisfying “browse company” and “browse users by company” with just one read that stays well under the 2-MB document limit. This pattern is explicitly recommended by Azure Cosmos DB data-modeling guidance for read-optimized workloads.

Why Incorrect

A. Separate docs require an extra query (or cross-document join) to fetch all users, so more RU/s and latency.
C. Two containers force fan-out queries across partitions/containers for “browse users by company,” increasing cost.
D. Duplicates company data in every user document, inflating storage and violating single-write principle; user-partitioned reads cannot return all company users efficiently.

References

1. Microsoft Docs – “Modeling relational data in Azure Cosmos DB”

section “Embed bounded 1-to-many relationships” (https://learn.microsoft.com/azure/cosmos-db/nosql/modeling-data)

2. Microsoft Learn module “Design a data model…”

unit “Embed vs. reference” (AZ-204 courseware)

slide 6.

Scroll to Top