What's the difference between Cloud Firestore and the Firebase Realtime Database?

FirebaseFirebase Realtime-DatabaseGoogle Cloud-PlatformGoogle Cloud-Firestore

Firebase Problem Overview


Google just released Cloud Firestore, their new Document Database for apps.

I have been reading the documentation but I don't see a lot of differences between Firestore and Firebase DB.

The main point is that Firestore uses documents and collections which allow the easy use of querying compared to Firebase, which is a traditional noSQL database with a JSON base.

I would like to know a bit more about their differences, or usages, or whether Firestore just came to replace Firebase DB?

Firebase Solutions


Solution 1 - Firebase

So I wrote an entire blog post all about this very question, and I recommend you check it out (or the official documentation) for a more complete answer.

But if you want the quick(-ish) summary, here it is:

Better querying and more structured data -- While the Realtime Database is just a giant JSON tree, Cloud Firestore is a little more structured. All your data consists of documents (which are basically key-value stores) and collections (which are collections of documents). Documents will also frequently point to subcollections, which contain other documents, which themselves can contain other documents, and so on.

This structured data helps you out in two ways. First, all queries are shallow, meaning that you can request a document without grabbing all the data underneath. This means you can keep your data stored hierarchically in a way that makes more sense to you without having to worry about keeping your database shallow. Second, you have more powerful queries. For instance, you can now query across multiple fields without having to create those "combo" fields that combine (and denormalize) data from other parts of your database. In some cases, Cloud Firestore will just run those queries directly, and in other cases, it will automatically create and maintain indexes for you.

Designed to Scale -- Cloud Firestore will be able to scale better than the Realtime Database. It's important to note that your queries scale to the size of your result set, not your data set. So searching will remain fast no matter how large your data set might become.

Easier manual fetching of data -- Like the Realtime Database, you can set up listeners in Cloud Firestore to stream in changes in real-time. But if you don't want that kind of behavior, and just want a simple "fetch my data" call, Cloud Firestore has that as well, and it's built in as a primary use case. (They're much better than the once calls in Realtime Database-land)

Multi region support -- This basically means more reliability, as your data is shared across multiple data centers at once. But you still have strong consistency, meaning you can always make a query and be assured that you're getting the latest version of your data.

Different pricing model -- While the Realtime Database primarily charges based on storage or network bandwidth, Cloud Firestore primarily charges based on the number of operations you perform. Will this be better, or worse? It depends on your app.

For powering a news app, turn-based multiplayer game, or something like your own version of Stack Overflow, Cloud Firestore will probably look pretty favorable from a pricing standpoint. For something like a real-time group drawing app where you're sending across multiple updates a second to multiple people, it probably will be more expensive than the Realtime Database.

Why you still might want the to use the Realtime Database -- It comes down to a few reasons.

  1. That whole "it'll probably be cheaper for apps that make lots of frequent updates" thing I mentioned previously,

  2. It's been around for a long time and has been battle tested by thousands of apps,

  3. It's got better latency and when you need something with reliably low latency for a real-timey feel, the Realtime Database might work better.

For most new apps, we recommend you check out Cloud Firestore. But if you have an app that's already on the Realtime Database, I don't really recommend switching just for the sake of switching, unless you have a compelling reason to do so.

Hope that helps!

Solution 2 - Firebase

You can read the whole article here: https://medium.com/@beingrahul/firebase-cloud-firestore-v-s-firebase-realtime-database-931d4265d4b0

Firebase Realtime database is stuctured as a JSON tree while Cloud Firestore stores data in documents (document is a set of key-value pairs) and collections (collections of documents).

More Structure Data

Realtime Database stores data in JSON tree while Cloud firestore stores data in documents which is very similar to JSON. enter image description here

In Cloud FireStore, Documents can conatins subcollections and nested objects(like ‘phone’ in above figure), both of which can include primitive fields like strings (like ‘name’, ’email’ in above figure) or complex objects like lists.

Better Querying

  • In the Realtime database, we can only sort or filter on a single property within a single query, not both sort and filter on a property. In the Cloud FireStore, You can chain filters and combine filtering and sorting on a property in a single query.
  • If you want to fetch data in descending order then Cloud FireStore is very useful for you. For the Realtime database, there is no query feature available. enter image description here
  • You can also chain multiple “where” methods to create more specific queries (logical AND) in Cloud FireStore. enter image description here

Scalability

Cloud Firestore will be able to scale better than the Realtime Database. It’s important to note that Your query performance is proportional to the size of your result set, not your data set. So searching will remain fast no matter how large your data set might become.

Manual fetching of data

We can listen data realtime in the Cloud FireStore like in Realtime Database but in the Cloud FireStore, we can also fetch data manualy (if you want to any data only one time).

Security

In the Realtime Database, We need to validate data separately using the validate rule but in the Cloud FireStore, data validation happens automatically.

Writing the data

We can execute multiple operations as a single batch and complete them atomically, with any combination of the set(), update() or delete() methods. enter image description here

Pricing

In the Realtime Database, charges only for bandwidth and storage, but at a higher rate. While in the Cloud FireStore, Charges primarily on operations performed in your database (read, write, delete) and, at a lower rate, bandwidth and storage.

Solution 3 - Firebase

Reasons to choose Cloud Firestore over Realtime Database

It is an improved version

Firebase database was enough for basic applications. But it was not powerful enough to handle complex requirements. That is why Cloud Firestore is introduced. Here are some major changes.

  • The basic file structure is improved.
  • Offline support for the web client.
  • Supports more advanced querying.
  • Write and transaction operations are atomic.
  • Reliability and performance improvements
  • Scaling will be automatic.
  • Will be more secure.

Pricing

In Cloud Firestore, rates have lowered even though it charges primarily on operations performed in your database along with bandwidth and storage. You can set a daily spending limit too. Here is the complete details about billing.

Future plans of Google

When they discovered the flaws with Real-time Database, they created another product rather than improving the old one. Even though there are no reliable details revealing their current standings on Real-time Database, it is the time to start thinking that it is likely to be abandoned.



Solution 4 - Firebase

Suggest link from google as well : Firebase Real-time Database vs FireStore

Extracted from google docs, a small sumamry here:

FireBase Real Time DB is JSON based NO SQL DB, meant for mobile apps, regional, and used typically to store and sync data between users/devices in realtime / extremely low latency.

FireStore is JSON 'like' NOSQL DB meant for high concurrency, global, easily auto scaling persistence, designed for any clients (not only mobile apps) with typical use cases such as asset tracking, real time analytics, building retail product catalogs, social user profile, gaming leaderboards, chat based applications etc.

Solution 5 - Firebase

While much of the answers are basically correct, Firebase documentation indicates it is not a simple matter of saying Firestore is the new way. It depends on what you want to do with the databases! Firebase asks you a number of questions in the link below, and consider carefully, because it's not so easy to write an app around one and then find out you need to use the other!

For example: Number of database instances: Do you need many databases, 1 for each major customer, or just 1 large database? If the former, use Firebase Realtime Database, if the latter use Firestore.

rtdb-vs-firestore

Solution 6 - Firebase

Cloud firestore is basically made for Simple but Big data and Realtime database is made for complex data storage (it looks like JSON)

Basic Intro. to both:-

  • Cloud Firestore is Firebase's newest database for mobile app development. It builds on the successes of the Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales further than the Realtime Database.
  • Realtime Database is Firebase's original database. It's an efficient, low-latency solution for mobile apps that require synced states across clients in realtime.

Main Diffrence:- Realtime database:::

  • Simple data is very easy to store.
  • Complex, hierarchical data is harder to organize at scale. Cloud firestore
  • Simple data is easy to store in documents, which are very similar to JSON.
  • Complex, hierarchical data is easier to organize at scale, using subcollections within documents.
  • Requires less denormalization and data flattening.

Source(more info..by google):- https://firebase.google.com/docs/database/rtdb-vs-firestore#key_considerations

Solution 7 - Firebase

  • Cloud Firestore is Firebase's database for mobile app development. It builds on the successes of the Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales further than the Realtime Database.

  • Realtime Database is Firebase's original database. It's an efficient, low-latency solution for mobile apps that require synced states across clients in realtime.

Solution 8 - Firebase

it usually ends up on the use case , if you are going to use higher bandwidth and having have the storage 98% of the time and use higher data processing then I would use fire store or else u can use the Realtime database .

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFrancisco Durdin GarciaView Question on Stackoverflow
Solution 1 - FirebaseTodd KerpelmanView Answer on Stackoverflow
Solution 2 - Firebase0xAliHnView Answer on Stackoverflow
Solution 3 - FirebaseBertram GilfoyleView Answer on Stackoverflow
Solution 4 - FirebaseTechFreeView Answer on Stackoverflow
Solution 5 - FirebaseezaspiView Answer on Stackoverflow
Solution 6 - Firebaseuser12449933View Answer on Stackoverflow
Solution 7 - FirebaseTarun SharmaView Answer on Stackoverflow
Solution 8 - FirebaseIshaan KotagarView Answer on Stackoverflow