NO SQL
RDMS was not designed to be distributed (but
comes with huge cost due to synchronization and
coordination )
HADOOP VS RDBMS.
WHAT IS A NOSQL DATABASE?
The NoSQL databases, sometimes also called
non-SQL, non-relational, or not only SQL
databases are those that have a different
mechanism to store and retrieve data other than
the tabular relations which are used in relational
databases.
No SQL is a schema-less (or a dynamic
schema-based) database.
NOSQL
The NoSQL databases comprise a wide variety of
database-related technologies to meet the
dynamic demands of modern applications.
Relational databases are not designed to meet
the demands of these applications(structured,
unstructured ,semi-structured) and development
environments.
NoSQL databases, like MongoDB, play a very
important role to allow the developers and the
development teams to focus on the application
programming part without worrying a lot about
the data complexities.
Developers feel a lot of flexibility and scalability
TYPES OF NOSQL DATABASE
MANAGEMENT SYSTEMS
There are four major types of NoSQL database
management systems. These are classified as
follows
Key-value paired databases
Column-oriented databases
Document-oriented databases
Graph databases
KEY-VALUE PAIRED DATABASES
These are the simplest NoSQL databases. Here,
the data is stored as a name (or key) with its
value
Examples of key-value paired databases are:
Berkeley DB
Redis
COLUMN-ORIENTED DATABASES
These types of NoSQL databases allow you to
store the columns of data instead of rows.
These are very effective in handling the queries
of large data sets.
Examples of column-oriented databases are:
Cassandra
HBase
DOCUMENT DATABASES
These databases pair each key with a data
structure called to document and these
documents then contain key-value pairs, key-
array pairs, and nested documents.
Examples of document databases are:
MongoDB
Couchbase
GRAPH DATABASES
These databases are useful in storing data that
are inter-connected as nodes just like a graph.
These databases add an extra layer of
highlighting the relationship among the
documents.
Examples of document databases are:
OrientDB
Neo4j
MONGODB
Document database
MongoDB documents are similar to JSON objects
and these documents can contain arrays, other
documents, or an array of documents
JSON Stands for JavaScript Object Notation and
it is one of the widely used open standard file
formats which uses human-readable text to store
and transmit data
EXAMPLE :JSON
{
"Students":[
{"firstName":"Siya", "lastName":"Sharma",
"Location":"India"},
{"firstName":"Ron", "lastName":"Smith", "Location":"USA"},
{"firstName":"Bash",
"lastName":"Tao","Location":"Philippines"}
],
"Teachers":[
{"firstName":“Divya", "lastName":"Sareen",
"Location":"India"},
{"firstName":"David", "lastName":"Baker",
"Location":"Canada"}
]
}
JSON data is specified in the name and value
pairs
Each data is separated by commas in JSON
The square brackets in JSON are used to hold an
array of object(s)
The curly braces in JSON are used to hold
object(s)
It is highly flexible and easy to understand as
you write JSON in a human-understandable
format.
COLLECTIONS
The MongoDB documents are stored in
collections. So you can consider this as a table
with respect to the relational database.
SUPPORT FOR RICH QUERY LANGUAGE
MongoDB uses rich query language to support
the CRUD (Create, Read, Update, and Delete)
operations.
It also supports the queries related to data
aggregation, search operations, as well as
geospatial queries.
THE DEFINITION OF MONGODB
According to the official website, MongoDB Inc.
MongoDB is a general purpose, document-based,
distributed database built for modern application
developers and for the cloud era.
Wikipedia defines MongoDB is a cross-platform
document-oriented database program. Classified
as a NoSQL database program, MongoDB uses
JSON-like documents with an optional schema.
MongoDB is developed by MongoDB Inc.
:
KEY POINTERS THAT DEFINE MONGODB
Document database
Cross-platform
Scalable
Flexible
Classified as a NoSQL database
CROSS-PLATFORM
MongoDB is a cross-platform database, which
means it can run on various operating systems
and on various computer architectures.
You can run MongoDB on Windows, Linux, and
even Mac Operating Systems
Officially MongoDB Inc. recommends these
platforms for production:
Amazon Linux 2
Debian 9 and 10
RHEL/CentOS 6, 7, and 8
SLES 12 and 15
Ubuntu LTS 16.04 and 18.04
Windows Server 2016 and 2019
SCALABLE
MongoDB is extremely scalable, suppose you are
developing an application that is presently not
widely used and has limited usage but you
believe that in the coming years, your application
will have a huge increase in new users and there
will be a multi-fold increase in the traffic.
MongoDB offers scalability for three different
metrics:
In terms of cluster
In terms of performance
Scalability in terms of data
FLEXIBLE
MongoDB doesn't heavily enforce schema but
uses dynamic schema, and hence, is also referred
to as a schema-less database.
This makes it a highly flexible database
THE ADVANTAGES OF USING SCHEMA-
LESS DATABASES ARE AS FOLLOWS
MongoDB an edge over the schema-related
databases where we first define the schema and
then add records or data.
The problem with the schema-related databases
is that each time we need to add one extra field,
we have to update our schema as we cannot add
a new record without adding an extra field.
MongoDB is flexible in terms of its data
structure.
MongoDB relies on the JSON-like data structure
which is very flexible in itself.
So when we need to add any new data in
MongoDB which has or more fields and where
each data is dynamic, we can easily add these
records to our database in MongoDB without any
issues as it won't restrict us and we are not
bound to a specific data structure to be added in
the database.
BASIC COMPARISON BETWEEN THE NOSQL
DATABASE AND THE SQL DATABASE
SQL database : NoSQL database
(MongoDB)
Relational database :Non-relational database
Supports SQL query language: Supports JSON
query language
Table based :A collection based and key-value
pair
Row-based: Document-based
Column-based :Field-based
Support for foreign key :No support for foreign
key
Support for triggers :No Support for triggers
Contains a predefined schema :Contains a
dynamic schema
Not fit for hierarchical data storage :Best fit for
hierarchical data storage
Vertically scalable - increases RAM: Horizontally
scalable - adds more servers
Emphasizes ACID properties (Atomicity,
Consistency, Isolation, and Durability) :
Emphasizes the CAP theorem (Consistency,
Availability, and Partition tolerance)
MONGODB DATABASE
A single MongoDB server consists of various
databases where each database is a physical
container of collections.
MONGODB COLLECTION
A collection in MongoDB is equivalent to a
database table of the SQL-based databases and it
exists within a single database.
It includes a group of MongoDB documents.
MONGODB DOCUMENT
A document can be defined as an instance of a
MongoDB collection.
It includes a set of key-value pairs.
All the documents include a dynamic schema which
means the documents that comprise of the same
collection do not need to have the same set of fields
and structure.
MONGODB TERMINOLOGY COMPARISON
WITH SQL DATABASES
SQL MongoDB
database database
Table collection
row document or BSON (Binary JSON)
Column field
Index index
table joins embedded documents
primary key primary key