Blog logo on a black background with the words "Discover What's Next in Tech!"

It's #FrontendFriday - Cloud Firestore & Cloud Storage & Realtime Database

Hello #FrontendFriday-Readers, in our Firebase series today we are looking at various options for data persistence.

Let's start by briefly explaining why Firebase storage solutions are so interesting:

  • Serverless architecture: We do not need our own server, do not have to write our own backend. Our application talks directly to the database (or other Firebase solutions)
  • Real-time data syncing: data can be synchronized to your own or, depending on the application, other devices within milliseconds
  • Offline cache: If you lose Internet access, the SDK caches the data locally and synchronizes it again when the connection is re-established
  • Firebase ecosystem: Normally you would use database A, as a backend solution B, map the authentication with C, etc. and integrate all this with each other. Firebase offers everything from a single source, which makes it much easier

Storage options

Firebase offers three solutions:

  • Cloud Firestore [1]: Cloud NoSQL database
  • Realtime database [2]: Cloud NoSQL database
  • Cloud Storage for Firebase [3]: Cloud object storage

In the following chapters, we will look at which of these we should use for our application.

What do we want to save?

To decide which storage solution to choose, we need to know what we want to store.

  • User-generated files such as audio, video, images
    • For this we use the Cloud Storage for Firebase
  • Data that can be mapped in a JSON structure
    • Here the Cloud Firestore as well as the Realtime database be used

Cloud Firestore vs. real-time database

Which of the two options we should use depends on a number of criteria. A selection of these is:

  • Is access to the data mainly read or write?
  • How large do I need to be able to scale?
  • What availability must the database have?
  • How complex is my data model?

To help you make a decision here, Firebase offers a tool that finds the right database based on a few questions: "Cloud Firestore or Realtime Database" [4]. If there is no great dependency on one solution, the different price models can still be a factor.

Security

So far we have talked about storing data, but what about securing access by unauthorized persons? Normally, a backend would have to secure access to the database and only offer data for which the user is authorized. Security on the client side is not expedient, as this could be manipulated (never trust the client).

The backend here is the storage solution itself, which is connected to Firebase Security Rules can be secured. All Firebase storage solutions support this. However, the syntax and options for restricting access depend in detail on the storage solution used.

 

Look forward to the next blog post about Firebase.

Click here for the previous blog post

Learn more about frontend development


Links

[1] Cloud Firestore

[2] Firebase Realtime Database

[3] Firebase Cloud Storage

[4] Choose a database: Cloud Firestore or Realtime Database

[5] Firebase Security Rules

Nico Mutter

About ME

Nico Mutter studied computer science (M.Sc.) and has been working as a software developer at doubleSlash in Friedrichshafen since 2016. His focus is on the architecture and development of IoT projects. He also has extensive expertise in 3D rendering and mixed reality.

All contributions from Nico Mutter

Learn more

Further information on our website and in our newsletter

Arrow up