When is Nesting OK in Firebase?

Firebase Data Structuring documentation explicitly says "Avoid creating nests". The main reason is that

when we fetch data for a node in Firebase, we fetch all of its child nodes as well.

With this in mind, is it efficient to wrap deep if the data is still denormalized properly?

For example, here's a possible Firebase structure for an app with geotags and geo-indexes by post language:

posts/{postId}
indexes/
        languages/
                  en/geohashes/{geohash}
                  es/geohashes/{geohash}
                  de/geohashes/{geohash}

      

Compare this to a completely flat structure:

posts/{postId}
index_en_geohashes/{geohash}
index_es_geohashes/{geohash}
index_de_geohashes/{geohash}

      

I find the first nested structure clean and self-documenting. Is it as effective as a flat structure? (Let's say the most common use case is "x geohash query language")

+3


source to share


1 answer


A query from a nested structure /indexes/languages/en/geohashes/

and a flat structure is /index_en_geohashes/

equivalent to computation.



+1


source







All Articles