MongoDB Assignment- 1

Basic Questions

  1. Run a MongoDB command that prints “Connected to a NoSQL Database” when you connect in the shell.
  2. Create three collections (keyvalueDB, documentDB, graphDB) in one MongoDB database to represent different NoSQL types.
  3. Insert two documents into a collection showing schema flexibility (MongoDB) vs fixed table in SQL.
  4. Run db.runCommand({ buildInfo: 1 }) and log database type to confirm MongoDB is document‑oriented.
  5. Insert a demo document with large array + nested object to showcase MongoDB’s flexibility/advantage.
  6. Connect to MongoDB shell and run db.serverCmdLineOpts() to see the default port.
  7. Create a document {company: “MongoDB Inc.”} in a collection about and query it back.
  8. Open mongosh in terminal to prove shell access.
  9. Create a collection students and describe it as “Like a SQL table”.
  10. Insert one document {name: “Alice”, age: 22} and explain it as MongoDB’s atomic unit.
  11. Run use library to define a new database.
  12. Insert and then display BSON representation of a document to demonstrate storage format.
  13. Write a simple JSON-like MongoDB document for a student with name and age.
  14. Show BSON by inserting binary data, explaining “BSON” stands for binary JSON.
  15. Insert a document using ObjectId + Date to demo BSON datatypes beyond JSON
  16. Launch MongoDB Compass and connect to your local DB.
  17. Signup to MongoDB Atlas and create a free cluster.
  18. In mongosh, run show dbs to display all databases.
  19. Run use school to create new DB.
  20. Run show collections in the shell.

Intermediate Questions

  1. Create one table in SQL and one MongoDB collection with same data, compare them side by side.
  2. Insert a document into collection to demonstrate document‑oriented storage.
  3. Write MongoDB shell commands to create a collection named employees.
  4. Insert a document into employees with fields: name, position, and salary.
  5. Show the command to display all documents from the employees collection.
  6. Insert without _id and check auto‑generated _id field.
  7. Show how to insert multiple documents at once into a collection.
  8. Write MongoDB shell command to switch to the ecommerce database.
  9. Insert same dataset in SQL table and MongoDB collection, compare structure.
  10. Display any inserted MongoDB document as key‑value structure.
  11. Insert and inspect BSON Date to show why BSON > JSON.
  12. Give an example of a nested document in MongoDB.
  13. Insert three BSON datatypes (NumberInt, Date, ObjectId) and query them.
  14. Write a MongoDB query to find all students with age greater than 18.
  15. Insert one doc with insertOne and multiple docs with insertMany.
  16. Connect DB with Compass and shell, compare the views.
  17. Show how to connect to a MongoDB Atlas cluster from CLI.
  18. Connect Atlas cluster remotely and local MongoDB, compare performance on inserts.
  19. Write a query to delete a document where name = “John”.
  20. Write a query to update the salary of an employee named “Alice” to 60,000.

Advanced Questions

  1. Create two collections flexibleUsers (MongoDB) and strictUsers (simulate table rules) showing schema flexibility.
  2. Design a MongoDB database for a library system with collections for books, authors, and members.
  3. Show a BSON example that contains string, number, boolean, date, array, and nested object.
  4. Write a MongoDB command to insert a user document with nested address and array of phone numbers.
  5. Create a document representing an order with fields: orderId, customer, items (array of objects), totalPrice.
  6. Setup MongoDB Atlas cluster, replicate nodes, and demonstrate failover support.
  7. Design a MongoDB document for a social media post with user, content, likes, and an array of comments.
  8. Insert 100,000 documents and check size in BSON vs exported JSON.
  9. Create a MongoDB command that inserts a document with a BSON Date type and retrieve only the year.
  10. Insert documents and try querying by _id to demonstrate why _id ensures uniqueness.