Firebase Realtime Database
What is Realtime Database?
The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in real time to every connected client.
When you build cross-platform apps like for Apple, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and it automatically receives updates with the newest data.
It stores and syncs data with the NoSQL cloud database. Data is synced across all clients in real time and remains available when your app goes offline.
What Data Model it uses?
Realtime database uses NoSQL cloud database to store and sync data.
NoSQL databases (aka "not only SQL") are non-tabular databases and store data differently than relational tables (it sometimes refers to any non-relational database).
Realtime Database stores data as one large JSON tree which makes it easier to store simple data but harder to organize complex, hierarchical data at scale.
What are the key features of a Realtime Database?
Realtime - Instead of typical HTTP requests, the Firebase Realtime Database uses data synchronization—every time data changes, any connected device receives that update within milliseconds.
Offline - Firebase apps remain responsive even when offline because the Firebase Realtime Database SDK persists your data to disk. Once connectivity is reestablished, the client device receives any changes it missed, synchronizing it with the current server state. Realtime databases have mobile-first, real-time SDKs and support local data storage for offline-ready apps.
Scaling - Scaling in Realtime Database requires sharding (database sharding splits a single dataset into partitions or shards), meaning scaling beyond 100,000 concurrent connections and 1,000 writes/second in a single database requires distributing your data across multiple databases.
Accessible from Client Devices - The Firebase Realtime Database can be accessed directly from a mobile device or web browser; there’s no need for an application server.
What query does Realtime Database support?
Data can be retrieved, sorted, and filtered from any of the databases through queries.
Realtime Database supports deep queries with limited sorting and filtering functionality. In a single query, you can either sort or filter, not both, on a property. By default, queries are deep which always returns the entire subtree.
What are Firebase Database Rules?
Security and data validation are available through the Firebase Realtime Database Security Rules, expression-based rules that are executed when data is read or written.
Realtime Database cascade rules require separate validation, the only security option for Realtime Database is the Firebase Database Rules. It also reads and writes rules cascade. The data needs to be validated separately using the ‘validate’ rule.
Subscribe to my newsletter
Read articles from Ujjwal Mahar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by