← Firebase learning pathFirebase · Module 4 of 10
Firestore data modelling
Design collections for fast, cheap queries.
📖 Key ideas
- Model data around screens and queries.
- Denormalise: duplicate small fields to avoid extra reads.
- Use subcollections for large lists (posts/{id}/comments).
- Keep documents small; avoid ever-growing arrays.
- Use counters or aggregation queries (count()) for totals.
💡 Real-life example: Denormalising is writing the customer name on each bill so you don't open the customer file every time.
DenormalisationDuplicating data for faster reads
Aggregation queryServer-side count/sum/avg
Fan-outWriting data to many places
Hot documentDoc written too often