firestore-data-modeling-patterns
SKILL.md
Firestore Data Modeling Patterns
Overview
Firestore is a NoSQL document database that requires careful modeling to optimize for query patterns, scalability, and cost. This skill provides patterns for structuring data effectively.
Subcollections vs. Root Collections
When to Use Subcollections
Pattern: users/{userId}/orders/{orderId}
Use When:
- Data is tightly coupled to a parent (orders belong to a specific user)
- Child data is always accessed via parent
- You don't need to query children globally across all parents
- Document hierarchy makes semantic sense