Danny Hutson

100 thoughts on “Common SQL Queries converted for the Firebase Database – The Firebase Database For SQL Developers #4

  1. Are you kidding me? the solution for the query:
    > SELECT * FROM Users WHERE Age = 28 && Location = 'Berlin';
    is generate another attribute that is the combination of both of them?
    no way! that must be a joke!
    So if you modify the Age of the user or the Location of the user you also have to modefy this shitty parameter aswell…. I'm very disappointed

  2. Really man, so we now need to pre-decide what queries we would need before structuring our database. And what if we miss one query and have our json structure already decided, is it really worth to change the json structure to accomodate just one query, that's making the developer's life hell, fix it man.

  3. It really feels like Firebase and Angular are thought up by IT hipsters without a proper computer science education. I mean, creating a reduntant attribute that will be hard to maintain, just to be able to make a query that involves more than one attribute… so you're telling me THIS is somehow the future, and more convenient than SQL? Give me a break, this is 2017, not 1977. Similarly, Angular transports us 15 years back and introduces spaghetti code 2.0, nice job. I'm starting to lose hope for Google if they don't step up their game and start learning from history.

  4. The last one, #8:
    Seems more like a "hack" than a solution. Often when developing an app, when you set up the db tables, you are thinking of valid info that is going in and not of how you MIGHT have to query it later.Having to make those last minute entries just so you can query for age 28 and Berlin and get the answer seems simplistic and a big pain in the rear.

  5. Wow. This completely makes me certain I want to use MySQL as opposed to Firebase. WAY too much bullshit associated with Firebase queries.

  6. Hey, Database Developers! For those of you who are freaking out after example #8, I might recommend you check out Cloud Firestore. This is a new database from the Firebase team that has all of the nice features you'd expect from a Firebase product (nice client libraries, offline support, real-time data listeners, no managing your own infrastructure) but uses a document-object model. This means we can support some new capabilities like shallow queries and, yes, queries across multiple fields in documents.

    You can find a quick summary of all the differences between the two here: https://firebase.googleblog.com/2017/10/cloud-firestore-for-rtdb-developers.html

  7. For those of you who got let down by #8, maybe Firestore, a NoSQL cloud database from the same firebase team, will offer some hopes.
    Here is a snapshot of Firestore's querying capability:

    var citiesRef = db.collection("cities");
    citiesRef.where("state", "==", "CA")
    citiesRef.where("state", "==", "CA").where("population", "<", 1000000)

    ##Firestore is still in beta, but looks promising so far##

  8. the 8 is very very bad =( i like firebase, but its not good for a complex situation, the firestore i think is better for that.

  9. Hii,
    i am mitali
    I have one query
    var ref = admin.database().ref("dinosaurs");
    ref.orderByChild("height").on("child_added", function(snapshot) {
    console.log(snapshot.key + " was " + snapshot.val().height + " m tall");
    });
    its return an error
    FIREBASE WARNING: Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "category" at /diary to your security rules for better performance.
    Do you have ANY SOLUTION

  10. please i have this error " Query.orderByChild: You can't combine multiple orderBy calls." went i use the last query

  11. How to fetch data of user below age 50 and who lives in Berlin using indexes. Your suggested solution works on equals only.

  12. How can I can do an aggregation (OR) on firebase ? For example Select from Users where name = 'example1' or name='example2'? Thank you.

  13. Thank you for the great tutorials<

    I can't see OrderByChild(). I am using Xamarin.firebase 0.3.6
    I even tried to use .OrderBY("time") and it gives ( 400 Bad Request) can you please help me with this ?

  14. Anyone knows if the number #8 has a better way to work when it's necessary to make query like:

    "Select * from users where Location like 'B%' && age>30" …..

    This way on the video it's terrible! Unfortunately i think the best way is filter on client

  15. 10:47
    屌你都ON99,
    第一, dataset 幾十個組合我整到幾時
    第二, 本身firebase 都 data duplicate, 仲咁樣搞係咪痴線

  16. #8 is a step back. What if there are multiple AND in the WHERE statement? What if I change the age, then I also have to change the age_location, etc, etc.

  17. For everyone worrying about #8: Firebase's new Firestore has composite indexes to solve these.
    Check out from minute 10: https://www.youtube.com/watch?v=Ofux_4c94FI

  18. Everything was perfect except #8. totally destroyed the flow.. No way I am going to create such strange keys, in this case, please be open, you create one ref and then another ref inside to get specific data.

  19. Number #8 is a deal breaker… you say in the first video the advantage of NoSQL is I don't need to care about the schema at the start. But now you say I need to care about every single field permutation I might want in the future? What if 2 years into a lifecycle of an app users start to want to filter by 2 fields, with SQL I just slap a 'Where x and y' query under a button and I'm done, with this I need to somehow go over the entire DB file and create new keys?! Then there is the extra storage overhead on the server and performance degradation by comparing ever larger strings.

  20. i want to write two order by functions with less than and a greator than filers …how do i accomplish this task

  21. The last one killed Firebase for me.
    Something as simple as a query with 2 clauses cannot be impossible to do.
    What you did, changing the schema is surreal. What if you have 100 users? what if you have millions?
    You cannot possibly think that preddict the questions when building your data is doable.
    This renders something as common as multi filter in forms impossible.
    I was kinda going for the flexibility of NoSQL but so far your videos only taught me that NoSQL has more complex data structure, more complex and limited code to access it, and the only advantage I see is that changing the schema is easy, but that is not the problem with SQL. Creating a table takes 5min. Populating it another 10min. Why is this such a problem?
    I dont understand NoSQL permise.

  22. Best of your 8 part series so far.

    customerList: AngularFireList<any> ;

    this.customerList = this.angularFireDatabase.list('customers', ref => ref.limitToFirst(2));

  23. this one was really helpfull. thank you very much. is there a video about how to prewent children in the firebase with the same data, for example, i don't want to push to firebase if the email is already in the database,in other words, if there is a user with that email?

  24. #8 is a killer… Is this still the case? Or is there an update.? don't want to read the documention right now…

  25. #8 can we change the location as an index, something like this?

    "users":{

    "Berlin":{

    "9"{}

    }

    }
    i think for the field that we need to filter a lot, for example location, just change it to index.
    and the rest, filter it in client side.

  26. the last query really stupid thing.. this is one of the reasons i am seriously being resisted to move to NoSQL… I should know all the queries I am going to apply in the future while making my DB????

    If I was so foresighted then I'll be super awesome. And then NoSQL people say we don't have to worry about Schema changes in future coz there is no need to be so foresighted….

  27. How can I find user by uid starting with some text instead of equal to a text? Something like rootRef.child('user').child('1%')

  28. Instead of pulling all entries in a child ref, how can we select specific entries (key & value) from the data in Firebase? I'm having bad luck nesting with orderByChild() & I believe would need the on value listener event he began to mention.

    For Example (#2): SELECT Name from Users WHERE email = "[email protected]"

  29. Holy Mother SQL. Almost had an anxiety attack. Even though Firestore is available big brother, this should not be encouraged or promoted especially for younger developers. Or is it already a norm now? @[email protected] gulp.

  30. It's a evil query sintax I cannot found a simple query like this : select * from events where eventname like '%MEET%' and de case sensitive is a other evil

  31. How about adding startAftet and endBefore functions that do the same thing as greater than and smaller than operators?

  32. Now every time you update age or location you need to update age_location. Imagine if we have to do more combos. its messed up.

  33. The strategy of the eighth query in firebase is really awful. How can one then query the users in say two locations and in a certain age range. Assume the locations in our table are: SF, Berlin, Douala. How do I query all the users of age between 20 and 30 living in Berlin and Douala?

  34. #8 in 2019
    Firestore.instance

    .collection('task')

    .where('ownerId', isEqualTo: user.userData['id']).where('status', isEqualTo: 'OPEN')

    .snapshots(),

    Thank God

  35. i have 2 users Customer and Worker
    whenever customer books a worker for work the worker will get option to accept or decline

    and when customer books a work i store in firebase as "key"="bookingtimedateprogress" and its "value"="28-08-2019 01:30 AM Accepted/Declined"

    here i need to fetch data that startAt(time) and contains="Accepted"

    query1 = FirebaseDatabase.getInstance().getReference().child("App Data").child("Booking").child(userID).orderByChild("bookingtimedateprogress").startAt(currenttime)….. ???

    How can i user contains even with startAt

  36. 1. Number 4 (around 5:10): `4. Get all users names that start with…` In SQL would rather be `SELECT name` not `SELECT *`. Which brings me to the question – can we selectively select parts of json in NoSL databases?
    2. Number 5: `.endAt(49)` is ok when you know your values are integers. What if Age could be a floating number? Would I have to give a headroom to all possible decimals and say `.endAt(49.9999999999999999…)`?
    3. Number 5 vs number 7. In number 7, `less than 100` (`.endAt(100)`) is handled in a different way than `less than 50` in number 5. After watching number 5, I would expect that less than 100 would then be expressed as `.endAt(101)`
    4. Number 8 is **awful**. It actually contradicts everything you said about the flexibility at the beginning. If I have column `age` in all records, but at some point I need to add a new column (say, `location`), then the index would have to be created (flexibility?) and then the old records without `location` would have something like `28_undefined`? That syntax doesn't sound like a mature solution.

    I can see this video is dated back 2016, so I hope I will find a more up-to-date docs with improved syntax

Leave a Reply

Your email address will not be published. Required fields are marked *