MongoDB Interview Summary Questions

  1. What is MongoDB ?

  • MongoDB is an open-source NoSQL database written in C++ language.It uses JSON-like documents with optional schemas.
  • It provides easy scalability and is a cross-platform,document-oriented database.
  • MongoDB works on the concept of Collection and Document.
  • It combines the ability to scale out with features such as secondary indexes,range queries,sorting ,aggregations and geospatial indexes.
  • MongoDB is developed by MongoDB Inc.and licensed under the Server Side Public License(SSPL)

2. What are some of the advantages of MongoDB?

Some advantages of MongoDB are as follows:

  • MongoDB supports field,range-based,string-based,string pattern matching type queries.for searching the data in the database
  • MongoDB support primary and secondary index on any fields.
  • MongoDB basically uses JavaScript objects in place of procedures.
  • MongoDB uses a dynamic database schema
  • MongoDB is very easy to scale up or down.
  • MongoDB has inbuilt support for data partitioning (Sharding).

3.What is a Document in MongoDB?

A Document in MongoDB is an ordered set of keys with associated values.It is represented by a map,hash,or dictionary.In JavaScript,documents are represented as objects:

["greeting":"Hello world!"]

Complex documents will contain multiple key/value pairs:

{"greeting":"Hello world","views":3}

4.What is a Collection in MongoDB?

A collection in MongoDB is a group of documents.If a document is the MongoDB analog of a row in a relational database,then a collection can be thought of as the analog to a table.Documents within a single collection can have any number of different "shape",collections have dynamic schemas.

For example,both of the following documents could be stored in a single collection:

{"greeting":"Hello world!","views":3}

{"signoff":"Good bye"}

5.What are Databases in MongoDB?

MongoDB groups collections into databases.MongoDB can host several databases,each grouping together collections.

Some reserved database names are as follows:

  • admin
  • local
  • config

6.What is the Mongo Shell?

It is a JavaScript shell that allows interaction with a MongoDB instance from the command line.With that one can perform administrative functions,inspecting an instance,or exploring MongoDB.

7.What are some features of MongoDB?

  • Indexing: It supports generic secondary indexes and provides unique,compound,geospatial,and full-text indexing capabilities as well.
  • Aggregation:It provides an aggregation framework based on the concept of data processing pipelines.
  • Special collection and index types:It supports time-to-live(TTL)collections for data that should expire at a certain time
  • File storage:It supports an easy-to-use protocol for storing large files and file metadata.
  • Sharding:Sharding is the process of spliting data up across machines.

8.How to add data in MongoDB?

The basic method for adding data to MongoDB is "inserts" To insert a single document,use the collection's insertOne method:

db.books.insertOne("title":"Start with Why")

9.How does Scale-Out occur in MongoDB?

The document-oriented data model of MongoDB makes it easier to split data across multiple servers.Balancing and loading data across a cluster is done by MongoDB.It then redistribute documents automatically.

The mongos acts as a query router,providing an interface between client applications and the sharded cluster.

Config servers store metadata and configuration settings for the cluster.MongoDB uses the config servers to manage distributed locks. Each sharded cluster must have it own config server.

10.How do you Update a Document?

Once a document is stored in the database,it can be changed using one of several update methods: updateOne,updateMany, and replaceOne,updateOne and updateMany each takes a filter document as their first parameter and a modifer document, which describes changes to make,as the second parameter.replaceOne also takes a filter as the first parameter,but as the second parameter.replaceOne aslo takes a filter as the first parameter, but as the second parameter replaceOne expects a document with which it will replace the document matching the filter.

10.How do you Delete a Document?

The CRUD API in MongoDB provides deleteOne and deleteMany for this purpose.Both of these methods take a filter document as their first parameter.The filter specifies a set of criteria to match against in removing documents.

> db.books.deleteOne({"_id": 3})

11.What are the data types in MongoDB?

  • Null
  • Boolean
  • Number
  • String
  • Date
  • Regular expression
  • Array
  • Embedded document
  • Object ID
  • Binary Data
  • Code

12.When to use MongoDB?

You should use MongoDB when you are building internet and bussiness application that need to envolve quickly and scale elegantly.MongoDB is popular with developers of all kinds who are building scalable applications using agile methodologies.

MongoDB is a great choice if one needs to :

  • Support a rapid iterative development.
  • Scale to high levels of read and write traffic - MongoDB supports horizontal scaling through Sharding,distributing data across several machines, and facilitaing high throughput operations with large sets of data.
  • Scale your data repository to a massive size.
  • Evolve the type of deployment as the business changes.
  • Store,manage and search data with text,geospatial,or time-series dimensions.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值