Create a MongoDB Atlas account at: https://www.mongodb.com/cloud/atlas/register. There is a tutorial.
MongoDB Atlas supports a free cluster with up to 512 MB storage. No credit card is required.
Login to Atlas. Create a free M0 cluster. Provide a cluster name.
Create a database user account with a password. Add your IP address to allow access to the cluster from your machine.
On the dashboard, there is information about the cluster. To get connection information, click on Connect button.
Connecting to MongoDB cluster can be done using MongoDB shell, MongoDB Compass application, or using a language library.
MongoDB Compass is a graphical query tool that runs on all major platforms. You can download and install it directly from the connection screen shown previously.To connect, provide the connection string for the cluster. It is possible to insert, query, and browse data.
The lab will use the Java client library. An example code file called SampleMongo.java is in the lab.
- MongoDB Introduction
- Creating a Collection
- Modifying Documents
- Querying using find()
- Mongo Java Driver API
To test your database, write Java code using VS Code. The file to edit is MongoDB.java. The test file is TestMongoDB.java. Fill in the methods requested (search for TODO). Marks for each method are below. You receive the marks if you pass the JUnit tests AND have followed the requirements asked in the question (including documentation and proper formatting).
- +2 marks - Write the method
load()to load the TPC-Hcustomerandordersdata into separate collections (like how it would be stored in a relational model). The data files are in the data folder. - +3 marks - Write the method
loadNest()to load the TPC-H customer and order data into a nested collection calledcustorderswhere each document contains the customer information and all orders for that customer. - +1 marks - Write the method
query1()that returns the customer name given a customer id using thecustomercollection. - +2 marks - Write the method
query2()that returns the order date for a given order id using theorderscollection. - +2 marks - Write the method
query2Nest()that returns order date for a given order id using thecustorderscollection. - +2 marks - Write the method
query3()that returns the total number of orders using theorderscollection. - +2 marks - Write the method
query3Nest()that returns the total number of orders using thecustorderscollection. - +3 marks - Write the method
query4()that returns the top 5 customers based on total order amount using thecustomerandorderscollections. - +3 marks - Write the method
query4Nest()that returns the top 5 customers based on total order amount using thecustorderscollection.
Total Marks: 20
Up to +2 bonus marks for demonstrating some other feature of MongoDB Atlas.
The lab can be marked immediately by the professor or TA by showing the output of the JUnit tests and by a quick code review. Otherwise, submit the URL of your GitHub repository on Canvas. Make sure to commit and push your updates to GitHub.






