Thursday, 1 September 2016

MongoDB Interview Questions and Answer for 1 Year Experienced

MongoDB Interview Questions and Answer for 1 Year Experienced

Question: Which field is Default Primary Key in MongoDB?
_id is a 12 bytes hexadecimal number which is unique in every document(record).
Formation of 12 Bytes
4 bytes (for the current timestamp) + 3 bytes (for machine id) + 2 (bytes for process id) + 3 (increment value).

Question: Can we store Regular expression in MongoDB?
Yes, We can do.
For this there is data type i.e Regular expression.

Question: How to store array in MongoDB?
Yes, We can do.
   "_id": ObjectId(7df78ad8902c), 
   "url": "http://www.example.com",
   "tags": ["mongodb", "database", "NoSQL"],   

Question: What is syntax to update the document in collection?
db.collectiontest.update(SELECTIOIN_CRITERIA, UPDATED_DATA)

Question: How to remove one document in collection?

Question: How to remove document based on search criteria?

Question: How to use limit with search?

Question: How to sort the documents?

1: Ascending Order
-1: Descending Order

Question: What is Replication in MongoDB?
Replication is the process of synchronizing data across multiple servers.
Replication increases data availability with multiple copies of data on different database servers.

Question: How replication works in MongoDB?
A replica set is a "group of mongod instances" that host the same data set.
In a replica set one node is primary node and remaining nodes are secondary.
In a replica one node is primary node that receives all write operations.
All data replicates from primary to secondary node.

Question: What is Sharding?
Sharding is the process of storing data records across multiple machines to meeting the demands of data growth.

Question: What is Map-reduce?
Map-reduce is a data processing paradigm for condensing large volumes of data into useful aggregated results.

Question: What is a Covered Query?
It is query in which all the fields in the query are part of an index and all the fields returned in the query are in the same index.

Question: How to get new id of inserted New document?
$newDocID = $data['_id']; 

Question: How to Find a document with ObjectID in mongoDB?
$item = $collection->findOne(array(
    '_id' => new MongoId('4e49fd8269cb898c0a000000')));

Question: What is use of $explain operator in mongoDB?
$explain operator provides statistics on the query.
Use of query

Question: How to Create New ObjectId in mongoDB?
newObjectId = ObjectId()

Question: How to ObjectId to String in mongoDB?

Question: What is use of $hint operator in mongoDB?
$hint operator forces the query to use the specified index to run a query.
Use of query

Question: What are the Limitations of Indexing?
  1. A collection cannot have more than 64 indexes.
  2. The length of the index name cannot be longer than 125 characters
  3. A compound index can have maximum 31 fields indexed

No comments:

Post a Comment