Firestore
In one sentence
What it is
Firestore is a document database. Instead of tables and rows, you store documents — structured objects similar to JSON — inside collections. Documents in the same collection do not need identical fields, so the schema can vary between records and evolve over time.
It is serverless: there is no instance to size or scale. You are billed for the operations you perform and the data you store, and capacity adjusts automatically.
Why it matters
Two properties make Firestore distinctive rather than merely convenient. The first is real-time listeners: a client subscribes to a query and receives updates automatically when matching data changes. Building that with a conventional database means writing a whole synchronisation layer.
The second is offline support. Mobile clients can read and write while disconnected, and changes reconcile when connectivity returns. For mobile applications this removes a substantial amount of difficult work.
Key concepts
- Document — a record holding fields, with a size limit that discourages storing large blobs. Large files belong in Cloud Storage with a reference in the document.
- Collection — a container of documents. Collections can be nested under documents to model hierarchy.
- Query — filters and orders documents. Queries are designed to scale with the size of the result rather than the size of the collection.
- Index — single-field indexes are automatic; queries combining multiple filters and ordering require a composite index you define.
- Real-time listener — a subscription that pushes changes to the client as they happen.
- Security rules — declarative authorisation evaluated on the server, allowing clients to talk to the database directly and safely.
- Transactions and batched writes — atomic operations across multiple documents.
Modelling for a document database
The habits of relational modelling work against you here. In a relational database you normalise and join at read time. In a document database you frequently duplicate data so that a single read returns everything a screen needs.
- Start from the screens in your application and work backwards to the documents.
- Denormalise deliberately — storing an author's display name on each post is normal, not a mistake.
- Keep counters and aggregates as maintained fields rather than computing them by reading many documents.
- Store large binary content in object storage and keep only the reference in the document.
Common use cases
- Mobile applications needing offline capability and automatic synchronisation.
- Collaborative tools where several users see updates live.
- Chat, notifications and activity feeds.
- User profiles, preferences and application state.
- Rapid prototyping where the schema is still changing frequently.
Certification relevance
Where this topic appears, and how deeply each exam goes into it. These are our own assessments based on published exam guides.
- Associate Cloud Engineer
Mainly selection: recognising when a document database is more appropriate than a relational one.
- Professional Cloud Developer
Data modelling, security rules, transactions and real-time listeners from an application perspective.
- Professional Cloud Database Engineer
Covered as part of operating a mixed database estate, including indexing and cost behaviour.
Practice questions
Databases practice questions
8 original questions with full explanations.
Related Certifications
Related Cloud Topics
- Cloud SQLManaged relational databases — MySQL, PostgreSQL and SQL Server — with automated backups, replication and failover.
- BigtableA wide-column NoSQL database built for very high throughput and low-latency lookups over enormous datasets.
- SpannerA relational database that scales horizontally across regions while keeping strong consistency and SQL semantics.
- Cloud StorageObject storage for files of any size: buckets, storage classes, lifecycle rules and access control.