### Q6: Why does Profiler use in MongoDB? ☆☆
**Answer:**
MongoDB uses a database profiler to perform characteristics of each operation
against the database. You can use a profiler to find queries and write operations
### Q7: If you remove an object attribute, is it deleted from the database? ☆☆
**Answer:**
Yes, it be. Remove the attribute and then re-save () the object.
### Q8: Does MongoDB need a lot space of Random Access Memory (RAM)? ☆☆
**Answer:**
No. MongoDB can be run on small free space of RAM.
### Q9: What is a replica set? ☆☆
**Answer:**
It is a group of mongo instances that maintain same data set. Replica sets
provide redundancy and high availability, and are the basis for all production
deployments.
### Q10: Does Mongodb Support Foreign Key Constraints? ☆
**Answer:**
No. MongoDB does not support such relationships. The database does not apply
any constraints to the system (i.e.: foreign key constraints), so there are no
"cascading deletes" or "cascading updates". Basically, in a NoSQL database it
is up to you to decide how to organise the data and its relations if there are
any.
### Q11: What Is Replication In MongoDB? ☆☆
**Answer:**
**Replication** is the process of synchronizing data across multiple servers.
Replication provides redundancy and increases data availability. With multiple
copies of data on different database servers, replication protects a database
from the loss of a single server. Replication also allows you to recover from
hardware failure and service interruptions.
### Q12: Which are the most important features of MongoDB? ☆
**Answer:**
* Flexible data model in form of documents
* Agile and highly scalable database
* Faster than traditional databases
* Expressive query language
*
### Q13: Compare SQL databases and MongoDB at a high level. ☆☆
**Answer:**
SQL databases store data in form of tables, rows, columns and records. This
data is stored in a pre-defined data model which is not very much flexible for today's real-world highly growing applications. MongoDB in contrast uses a flexible structure which can be easily modified and extended.
*
### Q14: How is data stored in MongoDB? ☆☆
**Answer:**
Data in MongoDB is stored in BSON documents – JSON-style data structures. Documents contain one or more fields, and each field
contains a value of a specific data type, including arrays, binary data and
sub-documents. Documents that tend to share a similar structure are organized as
collections. It may be helpful to think of documents as analogous to rows in a
relational database, fields as similar to columns, and collections as similar
to tables.
The advantages of using documents are:
* Documents (i.e. objects) correspond to native data types in many programming
languages.
* Embedded documents and arrays reduce need for expensive joins.
* Dynamic schema supports fluent polymorphism.
### Q15: Mention the command to insert a document in a database called school
and collection called persons. ☆☆
**Answer:**
```js
use school;
db.persons.insert( { name: "kadhir", dept: "CSE" } )
```
*
### Q16: What are Indexes in MongoDB? ☆☆
**Answer:**
Indexes support the efficient execution of queries in MongoDB. Without indexes,
MongoDB must perform a collection scan, i.e. scan every document in a collection, to select those documents that match the query statement. If an appropriate
index exists for a query, MongoDB can use the index to limit the number of
documents it must inspect.
*
### Q17: How many indexes does MongoDB create by default for a new collection? ☆
**Answer:**
By default, MongoDB created the _id collection for every collection.
*
### Q18: Can you create an index on an array field in MongoDB? If yes, what happens in this case? ☆☆
**Answer:**
Yes. An array field can be indexed in MongoDB. In this case, MongoDB would
index each value of the array so you can query for individual items:
```js
> db.col1.save({'colors': ['red','blue']})
> db.col1.ensureIndex({'colors':1})
> db.col1.find({'colors': 'red'})
{ "_id" : ObjectId("4ccc78f97cf9bdc2a2e54ee9"), "colors" : [ "red", "blue" ] }
> db.col1.find({'colors': 'blue'})
{ "_id" : ObjectId("4ccc78f97cf9bdc2a2e54ee9"), "colors" : [ "red", "blue" ] }
```
### Q19: When should we embed one document within another in MongoDB? ☆☆
**Answer:**
You should consider embedding documents for:
* *contains* relationships between entities
* One-to-many relationships
* Performance reasons
*
### Q20: What is BSON in MongoDB? ☆☆
**Answer:**
**BSON** is a binary serialization format used to store documents and make
remote procedure calls in MongoDB. BSON extends the JSON model to provide
additional data types, ordered fields, and to be efficient for encoding and
decoding within different languages.
Post a Comment
please do not enter any spam link in the comment box