If you are looking to build a backend using Firebase, you have two options at your disposal: the Realtime Database, and the Cloud Firestore. Firebase was originally built with the Realtime Database, and it is a preferred tool for many developers due to its low maintenance costs, low barrier of entry, and the ability to query the database rapidly. However, the Realtime Database has its drawbacks, which made some users turn to other products. In order to address this, and reach a wider audience, Firebase released a separate backend called the Cloud Firestore.
The Cloud Firestore is not a replacement for the Realtime Database, even though it was built to address many of the issues users were having with the original product. The Firestore is built on an entirely different infrastructure, focusing on priorities such as data integrity and complex querying. With that being said, let’s take a look at what the two options have to offer.
Realtime Database
Most developers choose the Realtime Database because it offers a system that can track live streams of data in real time. Features and applications such as live chat, real time games, real time collaboration, and location based events are all easily managed and implemented with this tool. The Realtime Database also allows the developer to make frequent writes and reads to the database, and if you are familiar with handling JSON data objects, you’ll be right at home. However, if you do choose this option, you have to be aware that it is not meant to handle complex queries on the dataset and that you will have to manage a heavily denormalized, flat database.
Cloud Firestore
The Cloud Firestore can be used on top of the Realtime Database, and it’s meant for developers who are looking for a more classic data schema, but would like to have the ability to use real time listeners. The Firestore will allow you to run large CRUD operations, and it will allow you to query data on multiple fields.
Basically, the Firestore is a tool built for developers who would like to have a much more complex tool at their disposal, while the Database is designed for accessibility. The choice ultimately depends on the requirements of each development project.