Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
You are designing a Firestore Standard edition data model for a multi-tenant issue-tracking application. Each project document can accumulate tens of thousands of issue records over time. Your application must minimize read latency and support two core query patterns:
status equals "open", ordered by priority descending.status equals "open" and priority is greater than 3, ordered by priority descending, displaying each issue with its projectName.How should you organize the data and configure your indexes?
issues subcollection under each project document, denormalize projectName into each issue document, and create composite indexes on status and priority (descending) for both Collection and Collection group query scopes.In Firestore, subcollections allow you to nest collections beneath individual documents to model one-to-many relationships where child records grow without bound. Denormalization duplicates frequently accessed attributes—such as projectName—into child documents to eliminate secondary lookups, while composite indexes pre-sort multi-field combinations across specific query scopes (Collection for a single path, Collection group for all collections sharing an ID) to serve complex queries in a single index scan.
/projects/{projectId}/issues/{issueId} keeps parent project documents small and well below the 1 MiB document size limit, ensuring parent reads stay fast.Collection-scoped composite index on (status ASC, priority DESC) lets Firestore jump directly to status == "open" and stream results already sorted by priority descending.Collection group-scoped composite index on (status ASC, priority DESC) supports querying collectionGroup("issues") with status == "open", priority > 3, and orderBy("priority", "desc") across every project simultaneously.projectName onto each issue document ensures the global view renders immediately from a single query without issuing extra parent document reads.status) before the range and sort field (priority), minimizing the number of index entries scanned.Unlike embedding arrays inside parent documents, subcollections scale seamlessly to tens of thousands of items per project. Unlike normalized root collections or improperly ordered indexes, combining denormalization with properly ordered Collection and Collection group composite indexes delivers both local and global views in a single, low-latency server-side index scan.
projectId field, rely on automatic single-field indexes to query status == "open", filter priority > 3 on the client, and read each referenced project document to obtain projectName.Root-level collections organize distinct entity types at the top level of the database and are commonly used for many-to-many relationships. Automatic single-field indexes are created by default on every non-exempt field to support basic single-field filters and compound equality (==) queries without manual index configuration.
status == "open") with a range filter or sort on a different field (priority > 3, orderBy("priority", "desc")); a manual composite index is required.priority > 3 on the client forces Firestore to scan, transfer, and bill for every "open" issue across all projects—even low-priority ones—dramatically increasing read latency and cost.projectId requires an extra document read to /projects/{projectId} for every issue returned in the global view just to display projectName.priority when filtering by status.You only needed simple single-field or compound equality queries on a few documents, had a many-to-many relationship where projectName did not need to be displayed alongside issue lists, and did not need to minimize read latency or read operations.
issues subcollection under each project document, store projectName only in the parent project document, and create a Collection-scoped composite index ordered by priority (descending) followed by status (ascending).Collection-scoped index ordered by priority then status without denormalization doesA Collection-scoped composite index indexes documents within a single collection path rather than across all subcollections sharing the same name. Placing priority before status in the index definition orders index entries primarily by priority and secondarily by status.
Collection group index: A Collection-scoped index cannot serve collectionGroup("issues") queries; global cross-project queries will fail unless an explicit Collection group index is configured.status) to precede range, inequality, and orderBy fields (priority) in a composite index so it can seek directly to matching values. Placing priority first either fails to match the query plan for single-project queries or forces Firestore to scan extraneous index entries across non-matching statuses.projectName exclusively on the parent project document forces the application to issue additional get() calls for every issue's parent document, inflating read latency.Collection indexes apply to individual collection paths and do not span subcollections across different parent documents.You only queried a single subcollection at a time without filtering by status equality first, and you never needed to display projectName or run cross-project collection group queries.
projectName only at the project root, and rely on automatic array-contains single-field indexes to filter and sort open high-priority issues.array-contains indexing doNested arrays and maps store structured lists directly inside a parent document, which is convenient for small, fixed-size data such as a user's three most recently visited rooms. By default, Firestore builds automatic single-field array-contains indexes so queries can check whether an array contains a specific exact element.
array-contains index matches exact element values (or exact map objects) rather than performing compound equality (status == "open"), range (priority > 3), and descending sort (orderBy("priority", "desc")) operations on subfields across array items.Each project had only a small, fixed list of items (such as a few tags or recent statuses) that never grew over time and only needed exact membership checks via array-contains.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated