Firestore Study Notes
Firestore is a fully managed, serverless document database for building mobile, web, and server applications with real-time synchronization and offline support. Data is stored as documents in collections, queried with a flexible model, and scaled automatically without managing servers or clusters. Firestore also offers Datastore mode for compatibility with the legacy Datastore API and entity model.
Key facts
- Firestore in Native mode stores JSON-like documents organized into collections and subcollections, with each document containing fields, maps, and arrays and a practical document size limit to design around.
- Real-time listeners let client applications subscribe to queries and receive updates automatically when data changes, which powers live chat, collaborative, and dashboard experiences without polling.
- Client SDKs for Android, iOS, and web provide offline persistence, caching data locally and syncing changes when connectivity returns, a feature server-side databases do not offer directly.
- Security Rules control access at the database level based on authentication and document data, and they must be configured because client-direct access bypasses your application server entirely.
- Queries support filtering, ordering, and limits, and composite indexes are created automatically or via configuration for complex queries; Firestore notifies you when a required index is missing.
- Transactions and batched writes ensure atomic updates across multiple documents, while strong consistency is provided for reads in Native mode within the database's regional or multi-region configuration.
- Firestore scales automatically to handle bursts, charges by reads, writes, and storage, and offers point-in-time recovery and scheduled backups for data protection on supported configurations.
- Datastore mode provides the same underlying storage with Datastore APIs, entity groups concepts, and eventual or strong consistency options suited to server-only applications migrating from App Engine.
- Integration with Firebase Authentication, Cloud Functions, and Firebase hosting makes Firestore the default backend database for many Firebase application architectures tested in scenario questions.
What the exam expects you to know
- Choose Firestore for mobile and web applications needing real-time sync, offline access, and a serverless document model without managing database infrastructure.
- Know the difference between Native mode for new Firebase-style apps and Datastore mode for existing Datastore workloads, and that a database can only use one mode.
- Recognize Security Rules as the enforcement mechanism for client access, distinct from IAM which governs administrative and server access through service accounts.
- Understand that Firestore queries require indexes for compound filters and that designing collections around your query patterns avoids collection scans across all documents.
- Identify Firestore as NoSQL document storage, not a relational replacement; scenarios needing complex joins and global SQL transactions point instead to Spanner or Cloud SQL.
- Remember pricing and scaling are usage-based and automatic, so exam answers about provisioning nodes or clusters do not apply to Firestore unlike Bigtable.
Firestore vs Bigtable: when to use which
Use Firestore when building user-facing applications that need document storage, flexible queries, real-time updates, and offline sync for mobile and web clients with minimal operational management. Use Bigtable when ingesting massive volumes of time-series or operational data at millions of operations per second with access primarily by row key and no need for client SDK features. The exam distinction is audience and scale pattern: app developers and live user data point to Firestore, while backend data engineering at petabyte scale points to Bigtable. See also the Bigtable notes.
Useful gcloud commands
gcloud firestore databases create --location=us-central1 --type=firestore-native
gcloud firestore indexes composite create --database='(default)' --collection-group=orders --query-scope=COLLECTION
gcloud firestore export gs://my-bucket/backup --database='(default)'Common exam traps
- Firestore documents have a size limit, so storing large binaries or unbounded arrays inside a document is an anti-pattern; large files belong in Cloud Storage with a reference in Firestore.
- Security Rules are not optional for client-accessed databases; relying only on application code leaves data exposed because clients connect directly to Firestore.
- Firestore does not support SQL joins; denormalization and subcollections are the intended data modeling techniques, not relational normalization.
- Hotspotting can occur with sequential document IDs in a collection under very high write rates, though automatic IDs distributed randomly avoid this problem by design.
Frequently asked questions
What is the difference between Native mode and Datastore mode?
Native mode is the full Firestore experience with real-time listeners, offline client caching, and mobile and web SDKs for new applications. Datastore mode uses the Datastore API and client libraries for server applications, without real-time or offline features, mainly for existing Datastore users. You choose the mode when creating the database and cannot switch it later.
How does Firestore secure direct client access?
Firestore uses Security Rules written in a dedicated language that evaluates each read and write against the authenticated user and the document data. Rules can allow users to access only their own documents and reject all other requests by default. Combined with Firebase Authentication, this provides safe direct client access without a custom API layer.
Can Firestore replace a relational database?
Firestore can replace a relational database only when the application fits a document model with denormalized data and query-driven design. It does not provide joins, complex multi-table transactions in SQL style, or ad hoc relational reporting. For those needs the exam expects Cloud SQL for regional apps or Spanner for global transactional systems instead.
Study aid disclaimer: Cloud Cert Notes is an independent educational study aid. It is not affiliated with, endorsed by, or sponsored by Google, Microsoft, Amazon, Oracle, or Alibaba. Google Cloud, Associate Cloud Engineer, and Cloud Digital Leader are trademarks of Google LLC; all other certification names and product names are trademarks of their respective owners. Always confirm service details against the official provider documentation before sitting an exam.