I have ask this question in stack overflow, but it's not a good place to ask this question, so please allow me to ask the same question here.
It's quite interesting that when people ask this kind of question on internet the answers are like:
- It's NoSQL, not relational database.
- Please structure your database
- Add some combination key to your data.
Thinking how to structure database is really interesting for me, however I am curious about is it really difficult to implement multiple query on firebase? is there a technical issue, performance issue, or any policy considerations ?
- filter most on the server, do the rest on the client.
- add a property that combines the values that you want to filter on.
- create a custom index programmatically.
And in
this question, proper data structure will allow you to query by multiple fields.
I have no problem with these solutions above if my app is not published yet. What if my app already online for 10 months? Should I redesign my database structure? Setup a backend sever or use cloud functions to migrate all the data or insert some combination keys in order to fit new query constraint?
If I setup a database structure below in parse server, I can do multiple query and sort without redesign my database or insert new combination keys. Parse and Firebase are all nosql database, but Parse can give multiple constraints where Firebase can not.
{
"movies": {
"movie1": {
"genre": "comedy",
"name": "As good as it gets",
"lead": "Jack Nicholson"
},
"movie2": {
"genre": "Horror",
"name": "The Shining",
"lead": "Jack Nicholson"
},
"movie3": {
"genre": "comedy",
"name": "The Mask",
"lead": "Jim Carrey"
}
}
}
English isn’t my first language, so please excuse any mistakes.
What I want to ask is not about how to structure database to fit query constraints, I am interested in why firebase can't do that? because it's a real-time db? multiple query constraints cost a lot? or there are some limitations from the architecture of Firebase?