logo
Firebase - Interview Questions and Answers
How would you structure data in Cloud Firestore for a social media app?
Use a collection-document model :

Users Collection : Store user profiles (e.g., { uid, name, email }).

Posts Collection : Store posts (e.g., { postId, userId, content, timestamp }).

Comments Subcollection : Nested under each post (e.g., { commentId, userId, text }).

Normalize data where needed to avoid duplication, but denormalize for performance (e.g., storing user names in posts).