DP-420 Exam QuestionsBrowse all questions from this exam

DP-420 Exam - Question 20


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?

Show Answer
Correct Answer: A

To optimize the data store for reading data while meeting the requirements, you should use a single container where each document represents either a company or a user. By using the company ID as the partition key, you can efficiently query all users associated with a particular company without needing cross-partition queries. This setup allows for optimized read operations as the data relevant to a company will be placed in the same partition. When a company's details page or its users are selected, the required information can be retrieved efficiently from the same partition. This design also handles scenarios where users might have data greater than 2 KB and ensures that browsing by company and listing users by company are straightforward and performant.

Discussion

16 comments
Sign in to comment
arnabdtOption: B
Sep 30, 2023

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. This design separates the users and companies into two different containers, with each container optimized for querying their respective entities. The user container uses the user ID as the partition key, which allows for efficient retrieval of individual users. The company container uses the company ID as the partition key, which enables efficient retrieval of all users associated with a particular company. Adding the company ID to each user document in the user container allows for easy and fast querying of users by company. Whenever a company or user profile is selected, the details page for the company and all related users can be retrieved by joining the data from the two containers using the company ID. This design meets all the requirements specified in the prompt, including efficient reading of data, browsing by company, and browsing users by company.

xRiot007
Jun 20, 2024

The filter for both queries is company ID. B would result in cross partition queries with are not optimized for reading. A is the correct answer - one container, company ID as partition key and you can distinguish users from companies using a type prop, so if I only care to browse for a company I will not retrieve all its users because that would be extra data irrelevant for my search.

Zyo
Jan 25, 2024

1000 users with more than 2kb data can still exceed the 2MB allowed document size (dont forgot the company itself has data), so D is obviously incorrect.

TRUESON
Oct 20, 2023

A is correct … We want users and companies on the same partition. This is done by using company id as partition key for both. As a compayid is a widely used filter thes data that are related can be covered from the same partition. we add a type pro to distinguish the two types

wojtekscOption: D
Jan 13, 2024

Option D provides a well-optimized data store design that enables efficient browsing and retrieval of data by company, as well as an easy way to view company details and associated users on a single page.

monniqOption: A
Mar 22, 2024

A is correct, since the company and users will be in the same partition ang can be retrived in an optimized way. You can use type property to query for the companies only, or users only. B is incorrect since users are partioned by userid and when retrieving users for a company it will be a cross-partition query (not optimal way) D will create large company documents and it is not an optimal way again. C again is not an optimal way since the query to get user by company will run cross partition.

imandoOption: D
Sep 30, 2023

D is correct answer. Googled other sites and they are showing D as answer.

akash211
Jan 29, 2024

B seems to be more optimized for reading data

WomapocOption: D
Feb 12, 2024

D is correct

biglebowski88Option: D
Dec 12, 2024

D. Last statement says it should be optimized for reads. reads with embedded documents is most efficient and less compute resource intensive.

vinayhat
Jan 25, 2024

none of the options address "Associate each user to only one company". Ideally there should be a hierarchical key of userid / companyid to meet this requirement

[Removed]Option: B
Sep 3, 2024

option B is the most suitable design to optimize the data store for reading data Partitioning data based on the company ID for companies and the user ID for users allows for efficient retrieval of data. When querying for a specific company or user, the partition key helps direct the query to the appropriate partition, minimizing the amount of data that needs to be scanned.

biglebowski88Option: A
Dec 14, 2024

I've changed my mind to A. A would not have the risk of hitting the 2mb size limit whilst also maintaining in partition queries based on the companyID partition key.

szkieletOption: A
Feb 2, 2025

definitely A

szkieletOption: D
Feb 16, 2025

Somebody has mention the limit.. But the limit of the document is up to 2MB not 2KB https://learn.microsoft.com/en-us/azure/cosmos-db/concepts-limits

matejkaOption: D
Mar 20, 2025

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. Here's why: Efficiency in Data Retrieval: By embedding user data directly into the company document, all relevant user details can be fetched in a single query using the company ID. This aligns with the requirement to display a company's details and all related users on the details page. Optimized for Read Operations: Embedding ensures that browsing by company or browsing users within a company doesn't require multiple queries or complex joins. This makes the design highly performant for read-heavy operations. Scalability: Since each company has less than 1,000 users, embedding users into a company document won't exceed size or scalability limits of most document databases. This approach is particularly effective when the use case prioritizes read performance and browsing-related data access patterns.

WimTSOption: A
Apr 14, 2025

1 container and companyID as partitionKey to avoid cross-partition queries, and separate documents to avoid hitting the 2Mb limit (1000 users * 2KB)