DP-420 · Question #72
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…
The correct answer is D. In a company container, create a document for each company. Embed the users into company. The correct answer is D: In a company container, create a document for each company and embed the users into company documents. The access pattern requires browsing by company and, when a company is selected, immediately showing all related users - a classic 'one-to-many with…
Question
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?
Options
- AIn a directory container, create a document for each company and a document for each user. Use
- BCreate a user container that uses the user ID as the partition key and a company container that
- CIn a user container, create a document for each user. Embed the company into each user
- DIn a company container, create a document for each company. Embed the users into company
How the community answered
(53 responses)- A13% (7)
- B8% (4)
- C2% (1)
- D77% (41)
Explanation
The correct answer is D: In a company container, create a document for each company and embed the users into company documents. The access pattern requires browsing by company and, when a company is selected, immediately showing all related users - a classic 'one-to-many with co-location' scenario. Since each company has fewer than 1,000 users (keeping documents within the 2 MB item size limit for most cases) and users are always accessed through their company, embedding users inside the company document means a single point read retrieves both the company and all its users, minimizing request count and RU cost. Options A and B store users and companies separately, requiring cross-partition joins or multiple reads. Option C embeds the company into each user document, leading to data duplication and requiring a query (not a point read) to retrieve all users for a company.
Topics
Community Discussion
No community discussion yet for this question.