MongoDB Quiz

 

  1. What is MongoDB?

Answer: MongoDB is a document-oriented NoSQL database that stores data in flexible, JSON-like documents.

  1. What are some advantages of using MongoDB over a traditional SQL database?

Answer: Some advantages of MongoDB include its scalability, flexibility, and ability to handle large volumes of unstructured data.

  1. What is a document in MongoDB?

Answer: A document in MongoDB is a set of key-value pairs, similar to a row in a SQL database.

  1. What is a collection in MongoDB?

Answer: A collection in MongoDB is a group of related documents.

  1. What is a database in MongoDB?

Answer: A database in MongoDB is a container for collections.

  1. What is the syntax for inserting a document into a collection?

Answer: db.collection.insertOne() or db.collection.insertMany()

  1. What is the syntax for finding documents in a collection?

Answer: db.collection.find()

  1. What is the syntax for updating a document in a collection?

Answer: db.collection.updateOne() or db.collection.updateMany()

  1. What is the syntax for deleting a document from a collection?

Answer: db.collection.deleteOne() or db.collection.deleteMany()

  1. What is indexing in MongoDB?

Answer: Indexing is the process of creating a data structure to improve the speed of data retrieval.

  1. What is the syntax for creating an index in MongoDB?

Answer: db.collection.createIndex()

  1. What is sharding in MongoDB?

Answer: Sharding is the process of splitting a large database into smaller, more manageable parts.

  1. What is the syntax for sharding a MongoDB database?

Answer: sh.enableSharding()

  1. What is replication in MongoDB?

Answer: Replication is the process of creating multiple copies of data to improve availability and fault tolerance.

  1. What is the syntax for creating a replica set in MongoDB?

Answer: rs.initiate()

  1. What is a backup in MongoDB?

Answer: A backup is a copy of a database or collection used for disaster recovery.

  1. What is the syntax for creating a backup in MongoDB?

Answer: mongodump

  1. What is a restore in MongoDB?

Answer: A restore is the process of recovering a database or collection from a backup.

  1. What is the syntax for restoring a backup in MongoDB?

Answer: mongorestore

  1. What is the syntax for connecting to a MongoDB database from the command line?

Answer: mongo --host hostname --port port_number

  1. What is a cursor in MongoDB?

Answer: A cursor in MongoDB is a pointer to the result set of a query.

  1. What is aggregation in MongoDB?

Answer: Aggregation is the process of grouping data and performing operations on those groups.

  1. What is the syntax for performing aggregation in MongoDB?

Answer: db.collection.aggregate()

  1. What is the MapReduce function in MongoDB?

Answer: The MapReduce function is a way to process large amounts of data in parallel.

  1. What is the syntax for using MapReduce in MongoDB?

Answer: db.collection.mapReduce()

  1. What is CRUD in MongoDB?

Answer: CRUD stands for Create, Read, Update, and Delete operations in MongoDB.

  1. What is the syntax for inserting a document in MongoDB using PyMongo?

Answer: db.collection_name.insert_one({"key": "value"})

  1. What is the syntax for inserting multiple documents in MongoDB using PyMongo?

Answer: db.collection_name.insert_many([{"key1": "value1"}, {"key2": "value2"}])

  1. What is the syntax for querying documents in MongoDB using PyMongo?

Answer: db.collection_name.find({"key": "value"})

  1. What is the syntax for updating a document in MongoDB using PyMongo?

Answer: db.collection_name.update_one({"key": "value"}, {"$set": {"new_key": "new_value"}})

  1. What is the syntax for updating multiple documents in MongoDB using PyMongo?

Answer: db.collection_name.update_many({"key": "value"}, {"$set": {"new_key": "new_value"}})

  1. What is the syntax for deleting a document in MongoDB using PyMongo?

Answer: db.collection_name.delete_one({"key": "value"})

  1. What is the syntax for deleting multiple documents in MongoDB using PyMongo?

Answer: db.collection_name.delete_many({"key": "value"})

  1. What is the $in operator in MongoDB?

Answer: The $in operator is used to match documents where the value of a field equals any value in a specified array.

  1. What is the $regex operator in MongoDB?

Answer: The $regex operator is used to match documents where the value of a field matches a regular expression.

  1. What is the $exists operator in MongoDB?

Answer: The $exists operator is used to match documents where the specified field exists or does not exist.

  1. What is the $gt operator in MongoDB?

Answer: The $gt operator is used to match documents where the value of a field is greater than a specified value.

  1. What is the $lt operator in MongoDB?

Answer: The $lt operator is used to match documents where the value of a field is less than a specified value.

  1. What is the $sort operator in MongoDB?

Answer: The $sort operator is used to sort documents in ascending or descending order based on the value of a field.

  1. What is the $group operator in MongoDB?

Answer: The $group operator is used to group documents based on the value of a field and perform aggregation functions like sum, average, and count.

  1. What is the $project operator in MongoDB?

Answer: The $project operator is used to include or exclude fields from the output of an aggregation query.

  1. What is the $match operator in MongoDB?

Answer: The $match operator is used to filter documents in an aggregation pipeline based on a specified condition.

  1. What is the $limit operator in MongoDB?

Answer: The $limit operator is used to limit the number of documents returned by an aggregation query.

  1. What is the $skip operator in MongoDB?

Answer: The $skip operator is used to skip a specified number of documents in an aggregation query.

  1. What is the syntax for creating an index in MongoDB using PyMongo?

Answer: db.collection_name.create_index("key_name")

Comments

Popular posts from this blog

AIDS Meanstack Sample questions

Express.js Registration form data 2 Server