Google Cloud Professional Cloud Developer — Question 272
You are a developer at a social media company. The company runs their social media website on-premises and uses MySQL as a backend to store user profiles and user posts. Your company plans to migrate to Google Cloud, and your learn will migrate user profile information to Firestore. You are tasked with designing the Firestore collections. What should you do?
Answer options
- A. Create one root collection for user profiles, and create one root collection for user posts.
- B. Create one root collection for user profiles, and create one subcollection for each user's posts.
- C. Create one root collection for user profiles, and store each user's post as a nested list in the user profile document.
- D. Create one root collection for user posts, and create one subcollection for each user's profile.
Correct answer: B
Explanation
The correct choice, B, is effective because it allows for a structured organization where each user's posts are easily accessible within their profile, enhancing data retrieval and management. Option A lacks the necessary structure for user posts associated with individual profiles, while option C complicates data access by nesting posts within profiles. Option D reverses the relationship by prioritizing posts over profiles, which is not suitable for the intended design.