Firebase offers two cloud-based, client-accessible document databases. We recommend new customers start with Cloud Firestore:
-
Cloud Firestore is the recommended enterprise-grade JSON-compatible document database, trusted by more than 250,000 developers. It's suitable for applications with rich data models requiring queryability, scalability, and high availability. It also offers low latency client synchronization and offline data access.
Realtime Database is the classic Firebase JSON database. It's suitable for applications with simple data models requiring simple lookups and low-latency synchronization with limited scalability.
What are some other important things to consider?
After thinking about the previous key considerations, you might be ready to choose a database. If you're still weighing advantages and disadvantages, this section covers other differences between Cloud Firestore and Realtime Database.
Data model
Both Realtime Database and Cloud Firestore are NoSQL Databases.
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Stores data as collections of documents.
Learn more about the Cloud Firestore data model. |
Stores data as one large JSON tree.
Learn more about the Realtime Database data model. |
Realtime and offline support
Both have mobile-first, realtime SDKs and both support local data storage for offline-ready apps.
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Offline support for Apple, Android, and web clients. | Offline support for Apple and Android clients. |
Presence
It can be useful to know when a client is online or offline. Firebase Realtime Database can record client connection status and provide updates every time the client's connection state changes.
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Not supported natively. You can build on Realtime Database's support for presence by syncing Cloud Firestore and Realtime Database using Cloud Functions See Build presence in Cloud Firestore. | Presence supported. |
Querying
Retrieve, sort, and filter data from either database through queries.
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Indexed queries with compound
sorting and filtering.
|
Deep queries with limited
sorting and filtering features.
|
Writes and transactions
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Advanced write and transaction operations.
|
Basic write and transaction operations.
|
Reliability and performance
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Cloud Firestore is a regional and multi-region solution that scales
automatically.
|
Realtime Database is a regional solution.
|
Uptime
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Extremely high uptime performance.
|
High uptime performance.
|
Scalability
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Scaling is automatic.
|
Scaling requires sharding.
|
Security
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Non-cascading rules that combine authorization and validation.
|
Cascading rules language that separates authorization and validation.
|
Pricing
Both solutions are available on the Spark and Blaze pricing plans.
Cloud Firestore | [ PREFERRED ] | Realtime Database |
---|---|---|
Charges primarily on operations performed in your database
(read, write, delete) and, at a lower rate, bandwidth and storage.
Cloud Firestore supports daily spending limits for App Engine projects, to make sure you don't go over the costs you're comfortable with. Read more about Cloud Firestore pricing plans. |
Charges only for bandwidth and storage, but at a higher
rate.
Read more about Realtime Database pricing plans. |
Using Cloud Firestore and Realtime Database
You can use both databases within the same Firebase app or project. Both NoSQL databases can store the same types of data and the client libraries work in a similar manner. Keep in mind the differences outlined previously if you decide to use both databases in your app.
Learn more about the features available in both Realtime Database and Cloud Firestore.
Ready to choose a database?
Hopefully this comparison has helped you settle on a Firebase database solution. Now you can learn how to add a database to your Firebase projects.
- For Cloud Firestore, take a look at Get started with Cloud Firestore.
- For Realtime Database, read the Get Started topic for your platform: Apple, Android, C++, Unity, Web, or REST.