Firebase provides two different NoSql databases to work with.
Both databases serve different needs, Realtime database comes handy when data synchronization and realtime updates are the most crucial and priority for your project. where Cloud firestore shines when it comes to content management and filtering.
Both of the databases have different billing model and both of them provides their free usage.
Realtime Database
Realtime Database is very handy and provides fast data transfer and real-time sync. It is best suited for chat messages or any other application where two or more devices are communicating in realtime. The realtime database is as simple as it looks. it works on the node, click model where each node can have multiple children and each child can have key and value.
Best Scenarios:
- Chat
- Simple Data Structure-based Nodes
- Simple sortable list (Ascending/Descending)
Disadvantages: Realtime Database doesn’t support powerful queries.
Cloud Firestore
Firestore is the next-gen database that Firebase offers and performs out of the box. It is one of the popular NoSql databases that is gaining popularity on the internet and Stackoverflow.
Firestore shines when you need to store and handle more complex data. It is based on the Collection & Documents model.
Firestore was introduced to overcome the limitation of Realtime Database which is the queries. Realtime only offers basic sorting and filtering and Firebase provides more advance and powerful queries.
It supports various data types like String, Number, Geo Location, Array, Map, Timestamp, etc.
Best Scenarios:
- Filterable List
- Complex Data handling
- Complex Dataset
Disadvantages: If handled poorly, Firestore can become very expensive. A proper data modeling is required to optimize the database.
