What is Mongo DB?
Mongo
DB is a document-oriented NoSQL database that can hold a lot of data. Instead
of tables and rows, Mongo DB employs collections and documents. Mongo DB's
fundamental data unit is key-value pairs, which are used to create documents.
In the same way that relational database tables include sets of documents and
functions, collections do as well.
Mongo DB is capable of handling a
large variety of data types. It's one of a slew of non-relational database
systems that have sprung out under the NoSQL banner, most especially for use in
big data applications and other processing activities involving data that
doesn't fit well into the traditional relational paradigm. Unlike relational
databases, Mongo DB's design is based on collections and documents rather than
tables and rows.
Mongo DB Features
1. Each database consists of
collections, which are comprised of documents. Each document is separate, with
a different number of fields. The size and content of each document may be
different.
2. The document's structure is based
on how programmers create classes and objects in various programming
languages.
3. For the rows, there is no need to
define a schema (or documents, as they are known in Mongo DB). Instead, fields
can be constructed on the fly.
4. Mongo DB's data model simplifies
the definition of hierarchical connections, the storage of arrays, and the
storage of other more complex structures.
5.
Scalability - Mongo DB systems are extremely scalable. Clusters have been
defined by companies worldwide, with some running 100 or more nodes
and millions of documents in the database.
How Mongo DB works
Mongo DB works using records, which
are documents that contain a data structure made up of field and value pairs. Mongo
DB’s basic data unit is the document. The documents resemble JavaScript Object
Notation, although they employ a binary JSON variation (BSON). These documents
have fields that are analogous to columns in a relational database. The values
contained can be a number of data formats, including other documents, arrays,
and arrays of documents. The main key will be used as a unique identifier in
documents.
For
data consistency, the NoSQL DBMS has a single master architecture, with
subsidiary databases serving as backups of the parent database. For automated
failover, operations are automatically replicated to those alternative
databases. Because it is a NoSQL tool, it does not use the traditional rows and
columns associated with relational database administration. It is a
collection-based and document-based architecture. A set of key-value pairs is
the basic unit of data in this database. It provides for different fields and
structures in documents.
{_id:
name: “Navindu”,
Age: 23,
Address: {{street: “192 Dewala street”,
city: “Makola”,
state:
“Kiribathgoda”,
zip: “13400”,
country: “SRILANKA”}}
}
Mongo DB has a highly elastic data
model that allows you to integrate and store data of various forms without
sacrificing powerful indexing options, data access, or validation criteria.
What this means is that instead of spending extra time preparing data for the database,
you can focus on making your data work harder. Mongo DB adds the _id column to
uniquely identify each document in the collection.
Key Components of Mongo DB Architecture
- _id — Every Mongo DB record must have this field. The _id field in a Mongo DB document represents a unique value. Mongo DB will automatically construct an _id field if you create a new document without one. So, in the case of the preceding customer table, Mongo DB will assign each document in the collection a 24-digit unique number.
- A collection is a set of documents in Mongo DB. In any other relational database management system (RDMS), such as Oracle or MS SQL, a collection is the equivalent of a table. A collection exists within a single database. As stated in the introduction, collections do not impose any kind of structure.
- Cursor - A cursor is a pointer to the result set of a query. Iterating through a cursor allows clients to retrieve results.
- Database - Similar to how a relational database management system (RDMS) is a container for tables, a database is a container for collections. A Mongo DB server can hold many databases. Document - A document is essentially a record in a Mongo DB collection. Field names and values will be found in the document.
- The abbreviation for JavaScript Object Notation (JSON) is JavaScript Object Notation. This is a simple text format for expressing structured data in a human-readable fashion.
- A name-value pair in a document is called a field. In relational databases, fields are similar to columns. A Field with Key-Value Pairs is depicted in the diagram below. In the example below, the Customer ID is one of the key-value pairs defined in the document.
5. Mongo DB vs. RDBMS:
You can directly compare Mongo DB
NoSQL to RDBMS and map the two systems' different terminologies: The table join
is an embedded document, the column is a field, the tuple/row is a document,
and the RDBMS table is a Mongo DB collection. The number of tables and the
relationships between them is shown in a normal relational database schema,
although Mongo DB does not use the idea of a relationship.
Examine the table below to see how a
professional NoSQL database like Mongo DB differs from a relational database
management system. Nine different analogies between the two have been explained
in this blog.
Mongo DB
- Database that is both document-oriented and non-relational.
- Document-based
- Field-based
- Key-value pair based on a collection
- Provides a JavaScript client for executing queries.
- Setup is relatively simple.
- SQL injection has no effect.
RDBMS
- Database with a relational structure
- Row-based
- Based on columns
- Based on a table
- Doesn't support querying using JavaScript
- Setup is not as simple as it appears.
- SQL injection is a serious threat
Data integrity is a well-known feature
of relational databases. Mongo DB does not have an explicit need for this.
To avoid orphan records and duplicates, RDBMS demands that data be
normalized first. Normalizing data necessitates the creation of more tables,
which requires the creation of more table joins, which requires the
creation of more keys and indexes. As databases grow in size, performance can
become a problem. Again, Mongo DB does not make this a necessity. Mongo DB is
adaptable and doesn't require data to be normalized before it can be used.
Comments
Post a Comment