Microsoft

DP-420 practice question 19

Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB · free question 19 of 20

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?
  • A. In a directory container, create a document for each company and a document for each user. Use the company ID as the partition key. Correct
  • B. Create a user container that uses the user ID as the partition key and a company container that uses the company ID as the partition key. Add the company ID to each user document.
  • C. 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.
  • D. 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

Storing company and user items as separate documents in one container partitioned by company ID lets a single-partition query return a company and all its users, which is efficient for every browse and details page. Embedding up to 1,000 users, some larger than 2 KB, in one company document can approach or exceed the 2 MB item size limit and makes every user change rewrite the whole company item, so a one-to-many relationship of this size should be referenced rather than embedded. Separate containers keyed by user ID force cross-partition queries to browse users by company, and embedding the company in each user duplicates data and still needs a cross-partition query to list a company's users.

Need the theory? Learn it free in the DP-420 course on Godlike Academy

Practice the whole free set

Answer all 20 free DP-420 questions with instant feedback, or unlock all 211 questions with Learn and Exam modes.