Open In App

Realtime Database vs Firestore

Last Updated : 09 Dec, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

Realtime Database:

  • Firebase is a real-time database that is a JSON datastore.
  • It’s totally unstructured which is a blessing and a curse.
  • It is the Firebase’s first and original cloud-based database.
  • This real-time database demonstrates very low latency.
  • Firebase Database Rules is the only security option for realtime database. 
  • What makes real-time databases popular is their awesome client libraries. Client Libraries let you connect from your app be it web, android or iOS directly to the database so you could save your JSON directly to the real-time database without transforming it at all and you could quickly fetch your data back with realtime change detection. The real-time database made our lives so much easier.

Realtime Database

Firestore:

  • Firestore is designed to work side by side with the realtime database, using firestore doesn’t mean abandoning the realtime database but you’ll likely find it’s better for most tasks.
  • Firestore is considered as the next generation of the real-time database.
  • It has great client libraries.
  • It has security rules, it works with cloud functions for firebase.
  • Firestore is structured data.
  • Firestore also supports complex queries.
  • Firestore scales based on your result set, not on your collections record count.
  • It provides synced states across clients in Database in App.

Firestore

Differences in Detail:

  • Firestore is a document collection database, if you’ve used Google Cloud datastore or MongoDB then you’ll be familiar there’s a strict pattern to firestore. First, you define a collection, then you add documents and each document supports sub-collection which contains their own documents so you can nest data much like did in the real-time database but it’s much more structured. Think collection then document collection then document. It’s a new pattern but it’s not hard to figure out.
  • Firestore has client libraries just like the realtime database, the firestore client library enables you to execute single query/queries or listen to a document or collection for changes unlike the realtime database your firestore queries can have multiple query and order by statements and unlike the realtime database, your firestore queries remain performant for massive collections.
  • The real-time database gets cranky if you force it to query over millions of records whereas firestore doesn’t care how complicated your query is or how many records are in the collection but firestore does care about how many records you returned. This is one of the main differences between firebase and firestore. The real-time database always bills you based on connection count and data transfer, firestore doesn’t bill you by connected client count but firestore does bill you by the volume of data transferred, and firestore bills you by your read-write and delete counts. So every record you pull from the database counts against your reads. You need to recognize that firestore scales based on the result set so if the feature you’re building has lots of fast small reads and writes stick to the real-time database but you’ll find most app features are much easier to build on firestore.
  • Firestore and Realtime Database both are NoSQL Databases. Realtime Database stores data as one large JSON tree whereas Firestore stores data in documents arranged in collections.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads