Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 22

What is NoSQL?

Stands for Not Only SQL


Class of non-relational data storage systems
Usually do not require a fixed table schema nor do they
use the concept of joins
All NoSQL offerings relax one or more of the ACID
properties (will talk about the CAP theorem)
Not only SQL.
Unstructured data from the web can include sensor data,
social sharing, personal settings, photos, location-
based information, online activity, usage metrics,
and more.
Trying to store, process, and analyze all of this unstructured
data led to the development of schema-less alternatives to
SQL.
Taken together, these alternatives are referred to as NoSQL,
meaning “Not only SQL.” While the term NoSQL
encompasses a broad range of alternatives to relational
databases, what they have in common is that they allow
you to treat data more flexibly.
Why NoSQL?
● here are different kinds of data that are structured,
unstructured and semi-structured and hence RDBMS
systems are not designed to manage these types of data
in an effecient way
● NoSql databases comes in to the picture and are
capable to manage it .

Just as there are different programming languages, need


to have other data storage tools in the toolbox
A NoSQL solution is more acceptable to a client now than
even a year ago
How did we get here?
Explosion of social media sites (Facebook, Twitter)
with large data needs
Rise of cloud-based solutions such as Amazon S3
(simple storage solution)
Benefits of NoSQL
managing data to scalability, it use has increased drastically.
Huge amount of data can be managed and then streamed.
Different kinds of data like structured and semi structured
data can be analyzed and analytical activities can be
performed.z
NoSQL Database Categories
Document Database– It pairs each key with a complex data
structure known as document. It can contain many
different key value pairs, or key array pairs or even nested
documents

Key value stores– They are the simplest NoSQL databases.


Every single item in the database is stored as an attribute
name or key together with its value.

Graph store– They are used to store information about


networks, such as social connections.Graph stores
include Neo4J and HyperGraphDB.

Wide column stores- Wide column stores such as Cassandra


and HBase are optimized for queries over large datasets,
An introduction to MongoDB
MongoDB
● MongoDB is an open-source document database that
provides high performance, high availability, and
automatic scaling.
● Database
Database is a physical container for collections. Each
database gets its own set of files on the file system. A
single MongoDB server typically has multiple databases.
● Collection
Collection is a group of MongoDB documents. It is the
equivalent of an RDBMS table. A collection exists within
a single database. Collections do not enforce a schema.
Documents within a collection can have different fields.
Typically, all documents in a collection are of similar or
related purpose.
● Document
A MongoDB document.
A record in MongoDB is a document, which is a data
structure composed of field and value pairs. MongoDB
documents are similar to JSON objects.
The values of fields may include other documents, arrays,
and arrays of documents.
NoSQL

• Key-value

• Graph database

• Document-oriented

• Column family
10
Key Features
● High Performance
MongoDB provides high performance data persistence. In
particular,

● Support for embedded data models reduces I/O


activity on database system.
● Indexes support faster queries and can include keys
from embedded documents and arrays.

11
Rich Query Language

MongoDB supports a rich query language to support read


and write operations (CRUD) as well as:

Data Aggregation
Text Search and Geospatial Queries(allow for the use of
geometry data types such as points, lines and polygons
and that these queries consider the spatial relationship
between these geometries.).

12
High Availability

MongoDB’s replication facility, called replica set, provides:

automatic failover and


data redundancy.

13
Document store
RDBMS MongoDB

Database Database

Table, View Collection

Row Document (JSON, BSON)

Column Field

Index Index

14
Join Embedded Document

Foreign Key Reference


Document store > db.user.findOne({age:39})
{
"_id" : ObjectId("5114e0bd42…"),
RDBMS MongoDB "first" : "John",
"last" : "Doe",
Database Database "age" : 39,
"interests" : [
"Reading",
Table, View Collection
"Mountain Biking ]
"favorites": {
Row Document (JSON, BSON) "color": "Blue",
"sport": "Soccer"}
Column Field }

Index Index

15
Join Embedded Document

Foreign Key Reference


JSON
● JSON (JavaScript Object Notation) is a
lightweight data interchange format. It is easy
for humans to read and write. It is easy for
machines to parse and generate.
● JSON is a text format that is completely
language independent but uses conventions
that are familiar to programmers of the C-
family of languages, including C, C++, C#,
Java, JavaScript, Perl, Python, and many
others.
● These properties make JSON an ideal data-
16
interchange language.
JSON is built on two structures:

1. A collection of name/value pairs. In various languages,


this is realized as an object, record, struct, dictionary,
hash table, keyed list, or associative array.
2. An ordered list of values. In most languages, this is
realized as an array, vector, list, or sequence.

17
_id
_id is a 12 bytes hexadecimal number which assures the
uniqueness of every document. You can provide _id while
inserting the document. If you don’t provide then
MongoDB provides a unique id for every document. These
12 bytes first 4 bytes for the current timestamp, next 3
bytes for machine id, next 2 bytes for process id of
MongoDB server and remaining 3 bytes are simple
incremental VALUE.

18
19
20
21
22

You might also like