Quiz

  1. Unrelated to today's reading, I have a question about file uploads. Is the /uploads used by multer a directory or a collection? If it is a directory, how can we sync it between users? If it is a collection, how can we store the files themselves directly instead of paths in MongoDB? Thank you!

    /uploads is a directory in your account. You can sync file uploads across users by transferring files using the drop command. If you really need to do this a lot, you could each make your /uploads folder world-writeable and allow your teammates to copy files over.

    But at this point, I imagine most of those files are test files, so it might be easier just to delete them and the database entities.

    I'm happy to consult with the team on these questions.

  2. Why did we not need to use the conn object earlier in the course, but it is necessary with transactions in MongoDB?

    Probably because the connection object is the singleton thing (object) that unites all the database transactions going to/from a particular app.

    MySQL also uses the connection object for transactions and commit().

  3. Could we go over the ACID operations? I didn't understand them

    Sure. The first three are variations on a theme:

    • Atomic: either the whole transaction happens, or none of it
    • Consistent: no one ever sees the database with a partially completed transaction
    • Isolation: even if, under the covers, things are happening concurrently, the state of the database is always as if things had happened sequentially (in isolation).
    • Durable: once a transaction is committed, the database never reverts to a previous state, and the changes last. Even, say, a power failure.
  4. Could you expand on the isolation section of ACID? Especially the part where it mentions "...depending on the isolation level used.." what do different levels of isolation look like?

    Isolation levels is from Relational Databases. There are certain anomalies that can happen, and which you might choose to allow in order to gain speed (concurrency). I have more information about this in the relational version of this course

  5. How do different levels of transaction isolation affect performance and consistency in a database

    Let's take just one example: "repeatable read". If you read the same data twice, do you always get the same value, or do you get an updated value? At the highest levels of transaction, once a value is read, you'll always get the same value. In practice in our applications, we rarely read a value more than once, so this doesn't affect us. But we could think about situations where it might. Maybe over a session?