0
0
GCPcloud~20 mins

Firestore collections and documents in GCP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Firestore Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Firestore Document Paths
Which of the following is a valid Firestore document path?
Aprojects/myproject/databases/(default)/collections/users/user123
Bprojects/myproject/databases/(default)/documents/users/user123
Cprojects/myproject/databases/(default)/documents/users
Dprojects/myproject/databases/(default)/documents/user123/users
Attempts:
2 left
💡 Hint
Remember that documents are stored inside collections, and the path includes 'documents'.
service_behavior
intermediate
2:00remaining
Firestore Document Creation Behavior
What happens if you try to create a Firestore document with a path to a non-existing parent collection?
AFirestore throws an error because the parent collection does not exist.
BThe document is created but the parent collection remains empty and invisible.
CFirestore automatically creates the parent collection and then the document.
DFirestore queues the creation until the parent collection is manually created.
Attempts:
2 left
💡 Hint
Think about how Firestore handles collections and documents dynamically.
Architecture
advanced
3:00remaining
Designing Firestore Data Model for Nested Collections
You want to store user profiles and each user's orders as nested collections. Which Firestore structure best supports efficient queries for all orders across users?
AStore all orders in a top-level collection with a userId field (orders/{orderId}).
BStore orders as fields inside each user document as arrays.
CStore orders as a subcollection under each user document (users/{userId}/orders/{orderId}).
DStore orders in a separate database instance linked to users.
Attempts:
2 left
💡 Hint
Consider how to query all orders regardless of user efficiently.
security
advanced
3:00remaining
Firestore Security Rules for Nested Collections
You want to allow users to read and write only their own orders stored in a nested collection users/{userId}/orders/{orderId}. Which security rule correctly enforces this?
GCP
match /users/{userId}/orders/{orderId} {
  allow read, write: if request.auth.uid == userId;
}
Aallow read, write: if request.auth.token.email_verified == true;
Ballow read, write: if request.auth.uid == orderId;
Callow read, write: if request.auth.uid != userId;
Dallow read, write: if request.auth.uid == userId;
Attempts:
2 left
💡 Hint
Match the authenticated user ID with the userId in the path.
Best Practice
expert
4:00remaining
Optimizing Firestore Document Size and Structure
Which approach best follows Firestore best practices to avoid exceeding document size limits and maintain efficient queries?
AStore large lists of items as subcollections instead of arrays inside documents.
BStore all related data in a single document to reduce reads.
CUse arrays inside documents to store thousands of items for fast access.
DDuplicate all data in multiple documents to avoid joins.
Attempts:
2 left
💡 Hint
Think about Firestore document size limits and query efficiency.