PCDE Design and implement database schemas Practice Question
A startup is using Firestore in Native mode for a real-time chat application. They want to design the schema for chat rooms and messages. Which TWO design patterns are recommended? (Choose two.)
⚠ Common exam trap
Firestore exams often test the misconception that arrays are suitable for storing related data, but Firestore arrays lack the indexing and scalability needed for relational-like references, leading candidates to incorrectly choose Option A.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use a composite index on chat room ID and timestamp.
A composite index on chat room ID and timestamp is essential for efficiently querying messages in order within a specific chat room. Firestore requires composite indexes for queries that combine equality filters on one field (chat room ID) with an order on another (timestamp). Option E is correct because storing messages as documents in a subcollection under each chat room document is the recommended pattern for Firestore, as it allows scalable, independent message collections per room without hitting the 1 MiB document size limit.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use arrays in the chat room document to store message IDs.
Why it's wrong here
Arrays have size limits and are not suitable for large numbers of messages.
- ✓
Use a composite index on chat room ID and timestamp.
Why this is correct
A composite index is required for querying messages efficiently.
- ✗
Store all messages in a single top-level collection with a field for chat room ID.
Why it's wrong here
A single large collection can be less efficient for filtering on chat room and timestamp.
- ✗
Use a separate top-level collection for each chat room.
Why it's wrong here
This results in many collections, which is not recommended due to collection limits and management overhead.
- ✓
Store messages as documents in a subcollection under each chat room document.
Why this is correct
Subcollections scale independently and allow efficient queries.
Go deeper
Related to this question
About these practice questions
This PCDE question is part of Courseiva's 1,446-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCDE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCDE exam.