Firebase Realtime Database

Realtime Database

I. Overview

Firebase Realtime Database plays a crucial role in providing a flexible and powerful solution for storing and synchronizing real-time data. Firebase Realtime Database uses a real-time model, allowing data to be synchronized immediately when changes occur.

Data in Firebase Realtime Database is stored in JSON format, creating a flexible and readable structure.

II. Compare with Firebase Firestore

Firebase offers two cloud-based, client-accessible document databases. We recommend new customers start with Cloud Firestore:

Data model

Both Realtime Database and Cloud Firestore are NoSQL Databases.

Cloud Firestore Realtime Database
Stores data as collections of documents.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. Stores data as one large JSON tree.Simple data is very easy to store.Complex, hierarchical data is harder to organize at scale.

In addition, there are many comparison factors that the Firebase homepage provides and recommends using Firestore. You can find more details at: https://firebase.google.com/docs/database/rtdb-vs-firestore 

III. Pricing

The cost of using Firebase Realtime Database is calculated based on several key factors. Here are some important points you should know:

Storage:

Read and Write Operations:

Realtime:

Geo-location:

Network Service Tiers:

Volume Discounts:

IV. Demo

Create database

Temporarily setting "allow read" and "write" to true allows for reading and writing. 

Go to Project Settings, download the google-service.json file, and copy the GoogleService-Info.plist file into the project.

Add lib:

Write:

Results on console:

Read: