In my opinion this is pretty obvious question when someone has to deal with a DB, so I don't know why I can't find anything about it.
I'm trying to design the non-relational database for my project. I have a list of products described by some info (e.g. the code, an image and a multi language description) and they are categorized in different ways. Here is a snap of the structure:
"products" : {
"-JiGh_31GA20JabpZBfa" : {
"code" : "IR3300000000",
"schema" : "http://lorempixel.com/400/200/",
},
"-JiGh_31GA20JabpZBfb" : {
"code" : "PJ0000000000",
"schema" : "http://lorempixel.com/400/200/",
}
}
"it" : {
"products" : {
"-JiGh_31GA20JabpZBfa" : {
"description" : "desc product IR330000000"
},
"-JiGh_31GA20JabpZBfb" : {
"description" : "description product PJ00000 lorem ipsum"
}
}
}
And below there are a couple of usages of the products, the real structure is much more complex, but probably it's enough to explain my problem:
"families" : {
"family1" : {
"products" : {
"-JiGh_31GA20JabpZBfa" : true,
"-JiGh_31GA20JabpZBfb" : true
}
},
"family2" : {
"products" : {
"-JiGh_31GA20JabpZBfa" : true
}
}
}
"applications" : {
"application_1" : {
"products" : {
"-JiGh_31GA20JabpZBfa" : true,
"-JiGh_31GA20JabpZBfb" : true
}
},
"application_1" : {
"products" : {
"-JiGh_31GA20JabpZBfa" : true,
}
}
}
Ok, now let's move to the client side!
I have a couple of tables, one that shows the families and one for the applications of the products. Selecting one of them I want to show all products that belong to the family or that are used in an application.
And here is what I'm struggling with: if I want to show the description and the code of each product in a cell, do I have to perform a query for every product to retrieve their fields or can I use some sort of "IN" query? Something like select * from products where key IN {"-JiGh_31GA20JabpZBfa", "-JiGh_31GA20JabpZBfa"}
. I know that it's an SQL like query, but this was just to better explain myself.
Btw, I don't exclude that my way of designing the DB is wrong.