424

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?

Nicholas
  • 501
  • 2
  • 14
Francisco Durdin Garcia
  • 12,540
  • 9
  • 53
  • 95
  • 11
    Reads are faster on Firestore, Writes are faster on Firebase Real Time Database – DragonFire Mar 14 '20 at 05:06
  • 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 . – Ishaan Kotagar Mar 14 '22 at 19:13

5 Answers5

581

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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Todd Kerpelman
  • 16,875
  • 4
  • 42
  • 40
  • 1
    How does Google Cloud Datastore fit in? Naively it seems to have a lot of overlap with Cloud Firestore. @ToddKerpelman – Jon G Oct 04 '17 at 16:18
  • 5
    It does have a lot in common with Cloud Datastore. The biggest difference is the integration with Firebase, so you have access to the mobile and web SDKs along with a native offline mode, as well as the real-time synchronization features. Cloud Datastore is great for large scale server-side development where you manage your own connection to your app, such as running your own website on App Engine or via Compute/Container Engine. – Todd Kerpelman Oct 04 '17 at 22:43
  • This looks great! My only reservation is that it looks like Cloud Functions don't work very reliably with Cloud Firestore: https://firebase.google.com/docs/firestore/extend-with-functions. Any idea if and when this might be resolved? – ZenPylon Oct 05 '17 at 22:07
  • 3
    What does "strong consistency" really mean? CAP theorem states you *cannot* "be assured that you're getting the latest version of your data" in a distributed & available environment. Consistency, Availability, Partition Tolerance => pick 2. – charles-allen Oct 09 '17 at 01:25
  • Firebase Firestore, Can I use it with AngularDart – Tushar Rai Oct 11 '17 at 11:10
  • 2
    @ToddKerpelman Any chance you'd do a Cloud Firestore / Cloud Datastore comparison. The two seem awfully similar. – TheAddonDepot Oct 11 '17 at 12:29
  • 1
    But what if I want to fetch all full objects and not shallow? If I want to fetch the list of "books" a user owns ("books" is an array of references books documents in the books collection), then I have to do 100 queries if the user has 100 books.. – Van Du Tran Nov 25 '17 at 05:38
  • 1
    Hey @VanDuTran - The Firestore documentation says that you can create a query that will return all of the subcollections, but it won't work for that structure. For this use case, I think it makes sense to restructure the data to have "user" as a child of book documents (possibly users/user, and then get all books with users/user = user (IFFFF you are using FireStore). I like the RealTime Database better for this use case. – jessi Nov 26 '17 at 03:25
  • Could you elaborate on how much latency is expected to be different from Firebase? – Renan Jan 30 '18 at 17:25
  • One thing that is important not mentioned here is that To enable export and import Firestore, requires you to enable Google Cloud Billing. Which I feel shouldn't be required. In realtime Database, you can export and import without enabling Google Cloud Billing. – Aman Feb 07 '19 at 10:50
  • One thing that seems to be missing here is the change in how queries will work. In RTDB, you only have one structure, but you can query at any depth (up to the max of 32 levels), whereas in Firestore, as far as I can tell, you cannot query sub-field data. I could be wrong there (I hope I am!) but thus far my experiments seem to point to that conclusion. – Mike Burton Feb 08 '19 at 16:05
  • Very Important Info Missed: Real-Time Database is only available in the US! In Europe (for example), for legal reasons (Cloud Act etc ...), it is not very recommended. – Laurent Perroteau Nov 09 '20 at 16:40
  • I don't this above is true, if you base your app say Western Europe it allows you to. – Marin Jan 13 '21 at 14:18
  • One feature I like about Firestore is that it can generate random document IDs for you. Can the Realtime Database do something like this or do you have to roll your own random ID generator? – thdoan Dec 03 '22 at 18:38
29

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.



TylerH
  • 20,799
  • 66
  • 75
  • 101
Bertram Gilfoyle
  • 9,899
  • 6
  • 42
  • 67
  • 1
    "it is the time to start thinking that it is likely to be abandoned." can this really be said? It seems more ideal for simple use cases and pricing concerns at the very least. – Kevin Danikowski Nov 22 '21 at 22:29
4

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.

TechFree
  • 2,600
  • 1
  • 17
  • 18
1

enter image description here

To choose between Firebase Realtime database and Cloud firestore based on your application requirements, read official documentation here.

Vivek Kumar
  • 2,625
  • 2
  • 25
  • 33
-2
  • 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.
Tarun Sharma
  • 914
  • 9
  • 15