Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Google Cloud Certified Professional Cloud Developer · Google Cloud
Select one answer.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
Answer A. Comments in article subcollection: Standard Firestore pattern Scales infinitely Easy to query per article Clean data organization No size limits concerns
The best answer here is A. Store each comment in a subcollection of the article. Here's why: Scalability: Storing comments as subcollections within the article document allows you to handle an unlimited number of comments per article. Firestore scales well with large numbers of subcollections. Querying: You can easily query for comments related to a specific article using the collectionGroup() query. This allows you to retrieve all comments for an article without needing to know the specific comment IDs. Performance: Firestore's subcollection structure optimizes for reading and writing comments related to a specific article.
Let's look at why the other options are less ideal: B. Add each comment to an array property on the article: This approach is limited by the maximum document size in Firestore (1 MB). You'll run into issues if you have a large number of comments for a single article. C. Store each comment in a document and add the comment's key to an array property on the article: This approach is less efficient for querying comments related to a specific article. You'd need to perform multiple queries to retrieve all comments. D. Store each comment in a document and add the comment's key to an array property on the user profile: This approach is not ideal for retrieving comments related to a specific article. You'd need to query the user profile for each comment, which is inefficient.