Using Firebase Realtime Database with complicated queries

The Issue

Let’s say we had a Node A, every action any user makes it get stored as a child of this node. So each Node N, when the number of users is only 10K for example, will end up with a huge amount of data, and when a new user uses the app for the first time and gonna need the data in Node N, he ends up downloading the data of a 10k other users!

Is there a direct Solution?

I started first by trying to re-design the database. I tried to make it flatter, so whenever the user needs some data, he will find it in independently stored in its own node and he needs to query it separately.

Will this solution work always?

Absolutely no! It always depends on the logic of your app and the amount of or the type of data your app is working with. But keep always in your mind that whether you start small or big, always, give enough time to think well about how to store your data efficiently and what will happen when your app grows big.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store