Quiz

  1. are nosql databases made possible because of the larger storage sizes you mentioned?

    Well, it is always possible to have a NoSQL database for smaller sizes. However, it was the desire to handle larger data sets that prompted the creation of NoSQL databases. Prior to those larger data sets, everyone was very happy with relational databases, and they still are. MySQL and PostGres are among the most popular databases in the world.

  2. are collections the same as tables? do nosql documents not have to have all the columns possible to be stored as null if they aren't used like in sql?

    Yes, collections are like tables. Missing values are just not stored, as opposed to having null stored.

  3. Could you please give some more examples of real-world use cases for MongoDB instead of a relational database?

    Dialysis data for individual customers. Continuous Glucose Monitoring for individual customers. Point of Sale records of customer data. Web search data. Social media websites. Internet traffic through routers.

    Anything were there are lots of values, particularly if they are mostly independent, so we don't need joins and such.

  4. How does querying work in MongoDB compared to SQL databases? Are there performance differences with complex queries or joins?

    The query language was redesigned completely, so that the query specification is a (JSON) data structure, rather than a string to be parsed. My understanding is that this is to thwart SQL injection attacks from the ground up.

    There may be performance differences, but those are almost certainly less important than scale differences.

  5. Is MongoDB more optimizied than MySQL? Is there any advantage to using one over the other?

    I wouldn't say MongoDB is more optimized. If anything, MySQL builds on decades of optimizations of RDBMSes.

    Again, performance differences are secondary; it's all about scale, replication, sharding, etc.

    Projects would choose a database back end for reasons like:

    • Do I need horizontal scaling? Or can the data all fit on one server?
    • Which does our developer team know better?
    • Are we doing this in-house or renting a service?
  6. When is it typically advisable to use MongoDB/NoSQL over MySQL?

    Great question. See above: horizontal scaling, replication, sharding

  7. Could you please explain further how MongoDB uses callbacks if it returns values?

    I think we are using the word "return" in two different ways. The database back-end "returns" (delivers) values to the middleware in response to a query.

    In a synchronous I/O model, the requesting function has to wait for the result (return value) of the I/O operation.

    In an asyncronous I/O model, the requesting function designates another function that will receive the data, rather than waiting.

    The Node.js API to MongoDB uses the asynchronous I/O model. I did notice a Python API that seems to use a synchronous I/O model. See connect-mongodb.

  8. I don't think I have any specific questions, but some might come up when we review the list-things.js script in class.

    I'm sorry; it seems that some of the software updates in the past year have modified our local MongoDB implementation so that my examples no longer work.

    We can spend a few minutes looking at the code.

    However, my goal with this topic is not to teach new code, but to focus on concepts, like scaling, sharding, denormalization, avoiding joins, etc.

    If people would like me to get the example code running again, I'm happy to put it on my to-do list; just let me know.