Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB — Question 29
You have an Azure subscription.
You plan to create an Azure Cosmos DB for NoSQL database named DB1 that will store author and book data for authors that have each published up to ten books. Typical and frequent queries of the data will include:
• All books written by an individual author
• The synopsis of individual books
You need to recommend a data model for DB1. The solution must meet the following requirements:
• Support transactional updates of the author and book data.
• Minimize read operation costs.
What should you recommend?
Answer options
- A. Create a single container that stores author items and book items, and then items that represent the relationship between the authors and their books.
- B. Create three containers, one that stores author items, a second that stores book items, and a third that stores items that represent the relationship between the authors and their books.
- C. Create two containers, one that stores author items and another that stores book items. Embed a list of each author’s books in the corresponding author item.
- D. Create a single container that stores author items and book items. Embed a list of each author’s books in the corresponding author item.
Correct answer: D
Explanation
The correct answer is D because embedding a list of each author's books within the corresponding author item allows for efficient transactional updates and minimizes read operation costs by keeping related data together. Options A and B introduce unnecessary complexity by separating data across multiple containers, which can increase read costs and complicate transactions. Option C, while it does embed data, uses two containers, which doesn't optimize for read operation costs as effectively as option D.