1

In SQL, I have used nested sets to store hierarchical data. I am trying to do the same with Firebase. In theory, the hierarchy could be "n" levels deep, but in actuality will probably be only 5-7 levels deep.

I have done quite a bit of research. This Mongo DB documentation suggests only using nested sets on static trees. My data will change quite a bit over time. The same document leads to the conclusion that materialized path is the way to go.

Does anyone have experience with this?

Community
  • 1
  • 1
spdaly
  • 1,260
  • 2
  • 18
  • 35
  • I wrote a quick non-answer below. In general questions like "does anyone have experience with ..." are not a good fit for Stack Overflow, since they are very broad and it is hard to identify a correct answer. – Frank van Puffelen Sep 20 '16 at 15:48
  • @FrankvanPuffelen I agree with you. I was hoping to put a finer point on my request. I kept editing and re-editing. Eventually I punted and submitted the post. Thanks for the answer and the comment. – spdaly Sep 20 '16 at 15:51

1 Answers1

2

Storing data is never the problem, querying the data efficiently is. Given that the Firebase Database stores data in a JSON tree, it can naturally store hierarchies very efficiently. But the Firebase documentation recommends against such nested data structures, since they are harder to secure and to query efficiently.

But it all depends on what data you want to store and how your app wants to access it. For a good introduction, I recommend this article on NoSQL data modeling.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks for the last link. I lot of good insight on how to approach the problem. I'll start to stub out some examples. An additional challenge is the need for concurrency. Many users could be editing the document at the same time. – spdaly Sep 20 '16 at 15:57
  • Yup. That article is my favorite since I discovered it. It puts names to many of the things we've been promoting for years to Firebase developers. But getting started with a new database paradigm remains hard. I've found no substitute for "Just Do It and keep doing it until it feels more natural" . :-) – Frank van Puffelen Sep 20 '16 at 16:04