Monday 22 August 2016

MongoDb Technical Interview Questions and Answers

MongoDb Technical Interview Questions and Answers

Question: What is MongoDb in technical terms?
MongoDb is No-SQL database. MongoDb is document oriented means store data in JSON Format called BSON. Designed with High Scalability.

Question: What is Replication?
Replication is the process of synchronizing data across multiple servers. It provides redundancy and increases data availability with multiple copies of data on different database servers.

Question: What are benefits of Replication?
  1. (24*7) availability of data
  2. Disaster Recovery
  3. No downtime for maintenance
Question: What is data warehouse?
A data warehouse is a relational database that is designed for query and analysis rather than for processing. It usually contains historical data derived from transaction data. It separates analysis workload from transaction workload and enables an organization to consolidate data from several sources.

Question: What is auto sharding in MongoDB?
Sharding is a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.

Question: Why sharding used in MongoDB?
  1. In replication all writes go to master node
  2. Latency sensitive queries still go to master
  3. Memory can't be large enough when active dataset is big
  4. Local Disk is not big enough
  5. Vertical scaling is too expensive

Question: What are data type support by MongoDB?
String : This is most commonly used datatype to store the data.
Integer : This type is used to store a numerical value. Integer can be 32 bit or 64 bit depending upon your server.
Boolean : Store a boolean (true/ false) value.
Double : This type is used to store floating values.
Min/ Max keys : This type is used to compare a value against the lowest and highest BSON elements.
Arrays : This type is used to store multiple values into one key.
Timestamp : ctimestamp. This can be handy for recording when a document has been added or modified.
Object : This datatype is used for embedded documents.
Null : This type is used to store a Null value.
Symbol : This datatype is used identically to a string however, it's generally reserved for languages that use a specific symbol type.
Date : This datatype is used to store the current date or time in UNIX time format.
Object ID : This datatype is used to store the document's ID.
Binary data : This datatype is used to store binay data.
Code : This datatype is used to store javascript code into document.
Regular expression : This datatype is used to store regular expression.

Question: How to connect to MongoDb databae through PHP?
$db = new Mongo('mongodb://localhost', array(
    'username' => 'abc',
    'password' => 'abc@123',
    'db'       => 'abc'

Question: How to Export database in MongoDb?

Question: How to Import database in MongoDb?