CIS-3010 Lab Assignment #9: MongoDB

Due: Friday, May 5, 2023

Reading: Read the appropriate chapters/sections of: MongoDB: The Definitive Guide, 3rd Edition. Log in using your VTC credentials.

In this lab you will experiment with the NoSQL system, MongoDB.

The goal of this assignment is to create a document oriented database, using MongoDB, that mimics some functionality of the PeakBaggers database you worked with earlier. Proceed as follows:

  1. Using the mongo shell, select the database you want to create (use dbname, where dbname is the name of the database you want to create). As with PostgreSQL please prefix the database name with your initials to prevent name conflicts and to make it clear which database belongs to whom.

    You can also create a database using MongoDB Compass (a GUI interface to MongoDB). However, for most of this lab I would prefer you use the shell and report on the specific commands you used to insert, query, and update documents.

  2. Add several "documents" into a mountain collection. You should include information that is similar to what you used with the PeakBaggers database, although feel free to demonstrate Mongo's flexibility by including some documents with unusual attributes. If you create the collection manually, you only need to specify 3 or 4 documents. Feel free to explore what would be required to export the mountain data from PeakBaggers into Mongo, but it is not required that you do so.

  3. Add several documents into a ascent collection, following what you did with PeakBaggers. One important difference is that you should include information about the climber who did the ascent using a sub-document (that is, an attribute with a value that is another JSON object). In this way your database will have no need for a "climbers" collection since that information will be kept with the ascents themselves. However, think about using the ObjectId of the mountain ascended (similar to a foreign key reference).

  4. Do a query or two on your data.

  5. Update one of your documents. Be sure to (at least) make use of the $set update operator.

Submit a document to Canvas that shows the commands you used for each of the parts above.


Last Revised: 2023-04-17
© Copyright 2023 by Peter Chapin <pchapin@vtc.edu>