Firebase Database Design
Click the image to zoom
*Notes:
- Timestamps are saved in milliseconds.
- All the ids are strings because they are unique combinations of alphanumeric characters generated by Firebase automatically when a new object is being created
Database Option
Based on the features, requirements, and size of the web application, we first decided what type of database was suitable for us. As the app did not need to establish many relationships between entities or to perform complex queries, we considered using a non-relational database.And since we wanted to add real-time synchronization and communication via the application, a notification system, we decided that using Firebase was the best option for us.
Since it was non-relational, document-type, some data was duplicated in these collections for a better accessibility.
Firebase is a cloud-hosted JSON database. It can synchronize data between the different clients immediately. Its schema-less structure and that Firebase Real-time Database can be characterized as a big JSON object that managed in real time allows flexible data modeling. Even if the user goes offline or lost his network connection, Firebase keeps an internal cache of the data and the app keeps working on that cache.
One of the greatest features in Firebase is the series of powerful tools that simplify authentication system (email & password authentication or third-party providers auth), files storing, real-time synchronization and notification system.
But Firebase is not only a real-time cloud database. It offers a range of other services. We used Firebase Storage to store the files: product images, user profile images. The firebase storage is synchronized with Google Cloud Platform Storage. We, also, used the Firebase Authentication service for email and password based authentication. Because Firebase comes with cloud messaging and notification system, we made use of that when implementing notifications for the new activity of the followed supervisors and for the new messages in the conversations they are engaged into.
Even though it is a non-relational database and this might make the search operations more difficult, Firebase allows indexing and for more complex search operations, we will be using Elasticsearch. Elasticsearch is a search engine based on Lucene and it can be easily integrated with a Firebase-based app.
Author: Emanuela Colta