Issue
I'm working with Firebase and have seen somewhere you can work the data so that they are in groups.
In my app I'm going to have genres and sub genres of documentaries ie:
(Genre)
History {
(sub genre)
world history {
(items)
pyramids
}
hidden history {
(items)
pyrmids
}
}
As you can see some of the items will be the same. Instead of rewriting the same item over and over again, is there a way to add them to a group so both could access the same item?
Solution
There is no problem with duplicating data, when it comes to Firebase. This is a quite common practice, which is named denormalization
and for that, I recommend you see this video, Denormalization is normal with the Firebase Database.
When you are duplicating data, there is one thing that need to keep in mind. In the same way you are adding data, you need to maintain it. With other words, if you want to update/detele an item, you need to do it in every place that it exists.
In your case, you should consider augmenting your data structure to allow a reverse lookup like this:
pyrmids
|
--- "worldHistory": true
|
--- "hiddenHistory": true
Answered By - Alex Mamo
Answer Checked By - Robin (JavaFixing Admin)