← Firebase learning path
Firebase · Module 4 of 10

Firestore data modelling

Design collections for fast, cheap queries.

📖 Key ideas

  1. Model data around screens and queries.
  2. Denormalise: duplicate small fields to avoid extra reads.
  3. Use subcollections for large lists (posts/{id}/comments).
  4. Keep documents small; avoid ever-growing arrays.
  5. 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