MongoDB Notes - Madhu
MongoDB Notes - Madhu
Now we should be working in the MongoDB shell. To run the MongoDB shell, type the
following command:
Step 6 : Once you are in the MongoDB shell, create the database in MongoDB by typing this
command
MongoDB Notes
At any point if you want to check the currently connected database just type the command
db. This command will show the database name to which you are currently connected. This
is really helpful command when you are working with several databases.
To list down all the databases, use the command show dbs. This command lists down all the
databases and their size on the disk.
MongoDB Notes
Introduction to MongoDB :
MongoDB is a NoSQL database which stores the data in form of key-value pairs. It is an
Open Source, Document Database which provides high performance and scalability.
A Document is nothing but a data structure with name-value pairs like in JSON. It is very
easy to map any custom Object of any programming language with a MongoDB Document.
For example : Student object has attributes name, rollno and subjects, where subjects is a
List.
rollno : 1,
Apart from most of the NoSQL default features, MongoDB does bring in some more,
very important and useful features :
MongoDB provides high performance.
MongoDB has a rich Query Language, supporting all the major CRUD operations.
Auto Replication feature of MongoDB leads to High Availability.
MongoDB supports multiple Storage Engines.
When we save data in form of documents(NoSQL) or tables(RDBMS) who saves the
data? It's the Storage Engine. Storage Engines manages how data is saved in memory
and on disk.
Below are some of the big and notable organizations which are using MongoDB as database
for most of their business applications.
Adobe
LinkedIn
McAfee
FourSquare
eBay
MetLife
SAP
SQL NO SQL
Relational database Non-relational database
Supports SQL query language Supports JSON query language
Table based Collection based and key-value pair
Row based Document based
Column based Field based
Advantages of MongoDB :
MongoDB Notes
Create database :
Your created database (madhudb) is not present in list. To display database, you need to
insert at least one document into it.
MongoDB provides the insert () command to insert documents into a collection. The
following example shows how this can be done.
MongoDB Notes
Pattern matching can be achieved by the $regex operator. This operator can be used
to find for certain strings in the collection.
The ^ and $ symbol can be used for exact text searches with ^ being used to make
sure that the string starts with a certain character and $ used to ensure that the
string ends with a certain character.
The 'i' along with the $regex operator can be used to specify case insensitivity so that
strings can be searched whether they are in lower case or upper case.
The delimiters // can also be used for pattern matching.
MongoDB Notes
MongoDB Notes
Mongo-DB is a document database which provides high performance, high availability and
easy scalability.
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.
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.
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.
While creating Schema in MongoDB what are the points need to be taken in
consideration?
Combine objects into one document if you use them together. Otherwise, separate them
Yes, it is possible to move old files in the moveChunk directory, during normal shard
balancing operations these files are made as backups and can be deleted once the
operations are done.
To do safe backups what is the feature in MongoDB that you can use?
Journaling is the feature in MongoDB that you can use to do safe backups.
Objectld is composed of
Timestamp
Client machine ID
Client process ID
To inspect a source code of a function, without any parentheses, the function must be
invoked.
What is the command syntax that tells you whether you are on the master server or not?
And how many master does MongoDB allow?
Command syntax Db.isMaster() will tell you whether you are on the master server or not.
MongoDB allows only one master server, while couchDB allows multiple masters.
MongoDB Notes
Mention the command syntax that is used to view Mongo is using the link?
The command syntax that is used to view mongo is using the link is
db._adminCommand(“connPoolStats.”)
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.
For storing and retrieving large files such as images, video files and audio files GridFS is used.
By default, it uses two files fs.files and fs.chunks to store the file’s metadata and the chunks.