Firebase One-to-N

Have been using so much Firebase and tried different ways of doing One-to-N. I found this paragraph from Mongo summarized it well.

Embed the N side if the cardinality is one-to-few and there is no need to access the embedded object outside the context of the parent object
Use an array of references to the N-side objects if the cardinality is one-to-many or if the N-side objects should stand alone for any reasons
Use a reference to the One-side in the N-side objects if the cardinality is one-to-squillions


Firebase 101

It sounds like a great idea, but comes with interesting twists…

For one, the security rule is not easy…

“the basic gist is that the rules cascade, but they stop as soon as access is granted. So once you’ve granted access to one branch of your data model, that user has access to all child attributes. You can’t deny access farther down the tree.” From Chris

Second, still not sure how to ensure uniqueness, i.e., storing URL and wanting to ensure that URL hasn’t be saved before…