Google Cloud Professional Cloud Developer — Question 124

You are developing an application that will allow users to read and post comments on news articles. You want to configure your application to store and display user-submitted comments using Firestore. How should you design the schema to support an unknown number of comments and articles?

Answer options

Correct answer: A

Explanation

The correct approach is to store each comment in a subcollection of the article, which allows for an unlimited number of comments without altering the article document structure. Storing comments in an array on the article could lead to performance issues as the number of comments grows, while using an array property for user profiles does not associate comments directly with the articles they belong to.