I am fairly new to firebase and noSQL storage as a whole. For my small project I want to store many items that all fall into their respective categories.
Eg.
- FoodItems
- Egg
- Ham
- Toast
- Animals
- Frog
- Penguin
The categories themselfes (Animals and FoodItems) do not hold any other information. How should I store this dataset?
Just Create the Items and give them an attribute "Type"? Or rather have empty documents to store subcollections is?
CodePudding user response:
The best data model for a NoSQL database depends more on the use-cases you want to implement than on the inherent model of the data itself. Without knowing all the use-cases, I recommend to start with a simple data model, so indeed storing the category in a field (an array field if a food-item can have multiple categories).
To learn more about data modeling in NoSQL databases in general, I recommend reading NoSQL data modeling. To learn more about Firestore watch Todd's excellent video series: Getting to know Cloud Firestore.