Monday, 16 November 2015

MongoDB - Interview Questions/Answers - MongoDB


Q1. What do you understand by NoSQL databases? Is MongoDB a NoSQL database? Explain.
Ans: At the present time, the internet is loaded with big data, big users, big complexity etc. and also becoming more complex day by day. NoSQL is answer of all these problems, It is not a traditional database management system, not even a relational database management system (RDBMS). NoSQL stands for "Not Only SQL". NoSQL is a type of database that can handle and sort all type of unstructured, messy and complicated data. It is just a new way to think about the database.
Yes. MongoDB is a NoSQL database.

Q2. Explain - what is MongoDB?
Ans: Mongo-DB is a document database which provides high performance, high availability and easy scalability.

Q3. What is the difference between MongoDB and MySQL?
Ans: Although MongoDB and MySQL both are free and open source databases, there is a lot of difference between them in the term of data representation, relationship, transaction, querying data, schema design and definition, performance speed, normalization and many more. To compare MySQL with MongoDB is like a comparison between Relational and Non-relational databases.

MongoDb is the best NoSQL database because, it is:
  1. Document Oriented
  2. Rich Query language
  3. High Performance
  4. Highly Available
  5. Easily Scalable
Q4. What is a Namespace in MongoDB? Explain.
Ans: MongoDB stores BSON (Binary Interchange and Structure Object Notation) objects in the collection. The concatenation of the collection name and database name is called a namespace.
Namespace is a concatenation of the database name and the collection name. Collection, in which MongoDB stores BSON objects.

Q5. What is sharding in MongoDB?
Ans: The procedure of storing data records across multiple machines is referred as Sharding. It is a MongoDB approach to meet the demands of data growth. It is the horizontal partition of data in a database or search engine. Each partition is referred as shard or database shard.

Q6. Explain what is a replica set? And how it works?
Ans: A replica set is a group of mongo instances that host the same data set. In replica set, one node is primary, and another is secondary. From primary to the secondary node all data replicates. Across multiple servers, the process of synchronizing data is known as replication. It provides redundancy and increase data availability with multiple copies of data on different database server. Replication helps in protecting the database from the loss of a single server. 

Q7. While creating Schema in MongoDB what are the points need to be taken in consideration?
Ans: Points need to be taken in consideration are -

• Design your schema according to user requirements
• Combine objects into one document if you use them together. Otherwise, separate them
• Do joins while write, and not when it is on read
• For most frequent use cases optimize your schema
• Do complex aggregation in the schema
 
Q8. Explain what is the role of profiler in MongoDB?
Ans: MongoDB database profiler shows performance characteristics of each operation against the database. You can find queries using the profiler that are slower than they should be.  

Q9. Explain what are indexes in MongoDB?
Ans: Indexes are special structures in MongoDB, which stores a small portion of the data set in an easy to traverse form. Ordered by the value of the field specified in the index, the index stores the value of a specific field or set of fields.

Q10. Mention what is the basic syntax to use index in MongoDB?
Ans: The basic syntax to use in MongoDB is >db.COLLECTION_NAME.ensureIndex ( {KEY:1} ). In here the key is the name of the file on which you want to create an index, where 1 is for ascending order while you use -1 for descending order.   


No comments:

Post a Comment

Monads in Scala

Monads belongs to Advance Scala   concepts. It  is not a class or a trait; it is a concept. It is an object which covers other object. A Mon...