1) Give some history about MongoDB.
MongoDB came into existence when data increased exponentially on the internet. Thus, maintainence of database became very difficult in structured DB. MongoDB is a NoSQL (Not Only SQL) database which can handle and sort all type of unstructured and complicated data.
2) Write some advantages of MongoDB over other database.
MongoDB is a document type database which is a type of NoSQL database which provides:
- High performance
- High availability
- Easy Scalability
- Rich Query Language
3) What is "Namespace" in MongoDB?
MongoDB uses BSON (Binary interchange & Structure Object Notation) which stores object in collection. Thus, Namespace is the concatenation of Collection name and Database name.
4) Explain the use of Locks to maintain consistency.
MongoDB uses reader-writer Locks which allows multiple users to access and apply READ operation on database or collection. It only allows single WRITE operation for private access which helps in maintaining consistency.
5) Define "Sharding" in MongoDB.
Sharding is a process in which data is stored across multiple machines. It creates a horizontal partition in database where each partition is referred as database shard.
6) What is a Replica Set?
It is a group of Mongo instances that maintains same data set. Replica set provides redundancy and consists of two nodes "Primary Node" and "Secondary Node" within which all data replicates.
7) Explain the process to move old files into moveChunk directory?
It is acheive at a time of shard balancing when the functions are done then old files are converted to backup files and moved to moveChunk directory.
8) Does MongoDB support primary-key, foreign key relationship? If not, how can we achieve it?
By default, MongoDB doesnot support primary-key, foreign key relationship but we can achieve it by embedding one document into other document.
9) Write the syntax for Create and Drop Collection?
Create Collection syntax:
db.createCollection(name,options)
Delete Collection syntax:
10) How to use schema in MongoDB database?
MongoDB database has dynamic schema where we don't have to define the structure to create collections.
11) What is object composed of?
Object is composed of
- Timestamp
- Client machine ID
- Client process ID
- 3 byte incremented counter
12) Explain Indexes in MongoDB.
It is a special structure in MongoDB which allows easy traversing for small set of data. It consists of order by value for specific field. Index stores the value of specific set of fields.
13) Write syntax for Index in MongoDB?
Syntax:
db.COLLECTION_NAME.ensureIndex ( {Col_name:VALUE} )
14) Explain GridFS in MongoDB.
GridFS is used to retrieve large data files such as image, video, audio files.
Default method is fs.files, fs.chunks for storage of files metadata and chunks.
15) Write alternate database of MongoDB?
- CouchDB
- Cassandra
- Hbase
- Redis
- Riak
16) Why is MongoDB not chosen for a 32-bit system?
Mongo DB is not considered as a 32-bit system because for running the 32-bit MongoDB, with the server, information and indexes require 2 GB.
17) How does Journaling work in MongoDB?
Journaling is used to safe backups in mongodb.Write operations are saved in the memory while journaling is going on. The on-disk journal files are really dependable for the reason that the journal writes are habitual. Inside dbPath, a journal subdirectory is designed by MongoDB.
18) What is CRUD?
Mongodb provides CRUD operations that are create, Read, Update, Delete.
19) What is Aggregation in MongoDB?
Aggregations are operations that process data records and return computed results.
20) Which command is used for inserting a document?
database.collection.insert (document) is used for inserting a document.
21) What is the use of profiler?
Profiler is used to show the performance characteristics of every operation against the database.
22) What is embedded documents?
Embedded documents capture relationships between data by storing related data in a single document structure.
23) What is replica set oplog?
The oplog records all operations that modify the data in the replica set.
24) What is vertical scaling?
Vertical scaling adds more CPU and storage resources to increase capacity.
25) What is horizontal scaling?
Horizontal scaling divides the data set and distributes the data over multiple servers, or shards.