I need best practice tips to enhance the performance of my noSQL database (hosted on Firebase). Moreover, I need tips on how to structure the nodes.
The database stores product information, with three main properties:
$productId
/date
/category
/subcategory
On my website, I have three views:
- retrieve the last 4 products (orderBy date)
- retrieve last 4 products (by date) of category X
- retrieve last 4 products (by date) of category X and subcategory Y.
Note that I also have a node product_images, which have subnodes matching the productIDs. So constructing the databas as follows:
$categoryId
$subCategoryId
$productId
will not work as I need to know beforehand the $categoryId and $subCatrgoryId before I can match it with $productId. It would also make it difficult to retrieve the last 4 products.
How would I construct my noSQL database in an efficient way, and how would I retrieve the products with Firebase filtering it out with multiple restrictions?
I know that in Firebase you can use orderByChild and equalTo, but this only works on one restriction, whereas I have to deal with one to three.