Warning: My query would be more theoretical (sorry programmers, please bear with me). I am trying to get some idea on how to define the database structure for use in Firebase.
I am exploring the use of Firebase as a backend for a Review app (in Android) I am trying to build.
The app provides product details and review for products of different kinds. So here is an example use case.
- The products displayed in the app are of same type (say smartphones). In this use case, defining the database structure is easier. For every phone, I simply need to save the phone specs to Firebase and retrieve them into my app.
Root | +--Smartphone | +--Manufacturer Name +--Screen Size +--Screen Density +--Processor +--RAM,...
- The products displayed in the app are of different type (say smartphones, Car, Book,...). In this use case, defining the database structure becomes complex. I can simply define the data structure like
Root | +--Product | +--Manufacturer Name +--Screen Size +--Screen Density +--Processor +--RAM +--Fuel type (Petrol/Diesel/Electric) +--Vehicle Type (Sedan/Hatchback) +--Vehicle Price,...
However, the problem with above data structure is, when I am trying to make a product review for a smartphone, the data related to Car will remain blank. Same will be the case for a product review of a Car.
This problem can be solved by using Flattening the data structure. This is where I am confused.
Root | +--Smartphone | | | +--Manufacturer Name | +--Screen Size | +--Screen Density | +--Processor | +--RAM | +--Car | +--Fuel type (Petrol/Diesel/Electric) +--Vehicle Type (Sedan/Hatchback) +--Vehicle Price,...
However, all product reviews will be displayed in a single activity/fragment. Hence, there will not be different activities/fragments for every product type. Could someone provide me a clear picture of using flattened data structures in my use case?
Regards