0
0
Firebasecloud~20 mins

Document ID strategies in Firebase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Document ID Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Firebase Document ID uniqueness

Which statement best describes how Firebase ensures document ID uniqueness within a collection?

AFirebase automatically generates a unique ID for each document if none is provided, ensuring no duplicates within the collection.
BFirebase allows duplicate document IDs within the same collection but prevents duplicates across different collections.
CFirebase requires the user to manually check and prevent duplicate document IDs before adding documents.
DFirebase uses timestamps as document IDs to guarantee uniqueness across all collections.
Attempts:
2 left
💡 Hint

Think about how Firebase handles document creation when no ID is specified.

Architecture
intermediate
2:00remaining
Choosing document ID strategy for user profiles

You want to store user profiles in Firebase Firestore. Which document ID strategy is best to ensure easy retrieval and uniqueness?

AUse the user's email address as the document ID.
BUse Firebase's auto-generated IDs for each user profile document.
CUse the user's unique authentication UID as the document ID.
DUse a random UUID generated on the client side as the document ID.
Attempts:
2 left
💡 Hint

Consider which ID is guaranteed unique and consistent for each user.

security
advanced
2:00remaining
Security risks of predictable document IDs

What is a major security risk when using predictable document IDs like sequential numbers in Firebase Firestore?

AIt causes Firebase to reject writes due to ID conflicts.
BIt allows attackers to guess document IDs and access unauthorized data if security rules are not strict.
CIt increases Firestore costs because predictable IDs require more storage.
DIt slows down queries because Firestore indexes sequential IDs less efficiently.
Attempts:
2 left
💡 Hint

Think about what happens if someone can guess document IDs.

Best Practice
advanced
2:00remaining
Best practice for document ID length and readability

Which document ID strategy balances uniqueness, readability, and performance in Firebase Firestore?

AUse short, human-readable IDs like usernames without extra uniqueness checks.
BUse a combination of a short prefix and a timestamp to create IDs.
CUse long UUIDs (36 characters) for all documents regardless of use case.
DUse Firebase's auto-generated 20-character IDs for all documents.
Attempts:
2 left
💡 Hint

Consider what Firebase recommends for most use cases.

service_behavior
expert
2:00remaining
Effect of document ID choice on Firestore query performance

How does choosing sequential numeric document IDs affect Firestore query performance compared to using Firebase's auto-generated IDs?

ASequential numeric IDs cause hotspots in Firestore, reducing write performance and increasing latency.
BSequential numeric IDs improve query speed because documents are stored in order.
CThere is no difference in performance between sequential numeric IDs and auto-generated IDs.
DAuto-generated IDs cause hotspots because they are random and scattered.
Attempts:
2 left
💡 Hint

Think about how Firestore stores documents and handles writes.