Using Firebase Realtime Database with complicated queries

Last week, I had a client who uses Firebase as a backend service. One of the clear issues he found himself in, is that he didn’t well design his database when he created his app the first time, which when the app grew up so fast led to a big amount of mixed data, neither he could well analyze it nor the user was able to have a good UX (‘cuz of the big amount of unnecessary data he has to download despite the fact he needs it or no ).

The Issue