NoSQL
The NoSQL DBMS
NoSQL:
n A fast, portable, open-source RDBMS
n A derivative of the RDB database system
n Based on the “operator/stream paradigm”
n One common interpretation of NoSQL is “not only SQL” or like “non-
relational”
2
NoSQL
• NoSQL is a non-relational database management systems, different from traditional relational database
management systems in some significant ways.
• It is designed for distributed data stores where very large scale of data storing needs (for example
Google or Facebook which collects terabits of data every day for their users).
• These type of data storing may not require fixed schema, avoid join operations and typically scale
horizontally.
RDBMS NoSQL
- Structured and organized data - Stands for Not Only SQL
- Structured query language (SQL) - No declarative query language
- Data and its relationships are stored in - No predefined schema
separate tables. - Key-Value pair storage, Column Store,
- Data Manipulation Language, Data Document Store, Graph databases
Definition Language - Eventual consistency rather ACID property
- Tight Consistency - Unstructured and unpredictable data
- Prioritizes high performance, high availability
and scalability
NoSQL Examples
Hbase Cassandra Hypertable Accumulo Amazon SimpleDB SciDB Stratosphere flare
Cloudata BigTable QD Technology SmartFocus KDI Alterian Cloudera C-Store
Vertica Qbase–MetaCarta OpenNeptune HPCC Mongo DB CouchDB Clusterpoint ServerTerrastore
Jackrabbit OrientDB Perservere CoudKit Djondb SchemaFreeDB SDB JasDB
RaptorDB ThruDB RavenDB DynamoDB Azure Table Storage Couchbase Server Riak
LevelDB Chordless GenieDB Scalaris Tokyo Kyoto Cabinet Tyrant Scalien
Berkeley DB Voldemort Dynomite KAI MemcacheDB Faircom C-Tree HamsterDB STSdb
Tarantool/BoxMaxtable Pincaster RaptorDB TIBCO Active Spaces allegro-C nessDBHyperDex
Mnesia LightCloud Hibari BangDB OpenLDAP/MDB/Lightning Scality Redis
KaTree TomP2P Kumofs TreapDB NMDB luxio actord Keyspace
schema-free RAMCloud SubRecord Mo8onDb Dovetaildb JDBM Neo4 InfiniteGraph
Sones InfoGrid HyperGraphDB DEX GraphBase Trinity AllegroGraph BrightstarDB
Bigdata Meronymy OpenLink Virtuoso VertexDB FlockDB Execom IOG Java Univ Netwrk/Graph Framework
OpenRDF/Sesame Filament OWLim NetworkX iGraph Jena SPARQL OrientDb
ArangoDB AlchemyDB Soft NoSQL Systems Db4o Versant Objectivity Starcounter
ZODB Magma NEO PicoList siaqodb Sterling Morantex EyeDB
HSS DatabaseFramerD Ninja Database Pro StupidDB KiokuDB Perl solution Durus
GigaSpaces Infinispan Queplix Hazelcast GridGain Galaxy SpaceBase JoafipCoherence
eXtremeScale MarkLogic Server EMC Documentum xDB eXist Sedna BaseX Qizx
Berkeley DB XML Xindice Tamino Globals Intersystems Cache GT.M EGTM
U2 OpenInsight Reality OpenQM ESENT jBASE MultiValue Lotus/Domino
eXtremeDB RDM Embedded ISIS Family Prevayler Yserial Vmware vFabric GemFire Btrieve
KirbyBase Tokutek Recutils FileDB Armadillo illuminate Correlation Database FluidDB
Fleet DB Twisted Storage Rindo Sherpa tin Dryad SkyNet Disco
MUMPS Adabas XAP In-Memory Grid eXtreme Scale MckoiDDB Mckoi SQL Database
Oracle Big Data Appliance Innostore FleetDB No-List KDI Perst IODB
4
Primary NoSQL Categories
General Categories of NoSQL Systems:
Key/value store
(wide) Column store
Graph store
Document store
Compared to the relational model:
Query models are not as developed.
Distinction between abstraction & implementation is not as clear.
5
Key/Value Store DynamoDB
Azure Table Storage
Riak
Rdis
Aerospike
FoundationDB
LevelDB
Berkeley DB
The basic data model: Oracle NoSQL Database
GenieDb
BangDB
Database is a collection of key/value pairs Chordless
Scalaris
Tokyo Cabinet/Tyrant
The key for each pair is unique Scalien
Voldemort
No requirement for normalization Dynomite
(and consequently dependency KAI
MemcacheDB
preservation or lossless join)
Primary operations: Faircom C-Tree
LSM
KitaroDB
insert(key,value) HamsterDB
STSdb
delete(key) TarantoolBox
Maxtable
Quasardb
update(key,value) Pincaster
RaptorDB
TIBCO Active Spaces
lookup(key) Allegro-C
nessDB
HyperDex
SharedHashFile
Symas LMDB
Additional operations: Sophia
PickleDB
Mnesia
variations on the above, e.g., reverse lookup LightCloud
Hibari
OpenLDAP
iterators Genomu
BinaryRage
Elliptics
Dbreeze
RocksDB
TreodeDB
(www.nosql-database.org
www.db-engines.com
www.wikipedia.com)
6
Wide Column Store
The basic data model:
Database is a collection of key/value pairs
Key consists of 3 parts – a row key, a column key, and a time-stamp (i.e., the version) Accumulo
Amazon SimpleDB
Flexible schema - the set of columns is not fixed, and may differ from row-to-row
BigTable
Cassandra
Cloudata
Cloudera
Druid
Flink
One last column detail: Hbase
Hortonworks
HPCC
Column key consists of two parts – a column family, and a qualifier Hyupertable
KAI
KDI
MapR
MonetDB
OpenNeptune
Qbase
Splice Machine
Sqrrl
(www.nosql-database.org
www.db-engines.com
www.wikipedia.com)
7
Wide Column Store
Column families
Row key
Personal data Professional data
First Last Date of Job Date of
ID Salary Employer
Name Name Birth Category Hire
Column qualifiers
8
Wide Column Store
Personal data Professional data
First Last Date of Job Date of
ID Salary Employer
Name Name Birth Category Hire
First Middle Last Job Hourly
ID Employer
Name Name Name Category Rate
First Last Job
ID Salary Employer Group Seniority Bldg # Office #
Name Name Category
Last Job Date of Insurance Emergency
ID Salary Employer
Name Category Hire ID Contact
Medical data
One “table”
9
Wide Column Store
Row key
t1
t0
First Last Date of Job Date of
ID Salary Employer
Name Name Birth Category Hire
Personal data Professional data
One “row”
One “row” in a wide-column NoSQL database table
=
Many rows in several relations/tables in a relational database
10
Graph Store
AllegroGraph
ArangoDB
Bigdata
The basic data model: Bitsy
BrightstarDB
Directed graphs DEX/Sparksee
Execom IOG
Fallen *
Nodes & edges, with properties, i.e., “labels” Filament
FlockDB
GraphBase
Graphd
Horton
HyperGraphDB
IBM System G Native Store
InfiniteGraph
InfoGrid
jCoreDB Graph
MapGraph
Meronymy
Neo4j
Orly
OpenLink virtuoso
Oracle Spatial and Graph
Oracle NoSQL Datbase
OrientDB
OQGraph
Ontotext OWLIM
R2DF
ROIS
Sones GraphDB
SPARQLCity
Sqrrl Enterprise
Stardog
Teradata Aster
Titan
Trinity
TripleBit
VelocityGraph
VertexDB
WhiteDB
(www.nosql-database.org
www.db-engines.com
www.wikipedia.com)
11
Document Store
AmisaDB
The basic data model: ArangoDB
BaseX
The general notion of a document – words, phrases, sentences, paragraphs, sections, Cassandra
Cloudant
Clusterpoint
subsections, footnotes, etc. Couchbase
CouchDB
Densodb
Flexible schema – subcomponent structure may be nested, and vary from Djondb
EJDB
document-to-document.
Elasticsearch
eXist
FleetDB
Metadata – title, author, date, embedded tags, etc. iBoxDB
Inquire
JasDB
Key/identifier. MarkLogic
MongoDB
MUMPS
NeDB
NoSQL embedded db
One implementation detail: OrientDB
RaptorDB
RavenDB
Formats vary greatly – PDF, XML, JSON, BSON, plain text, various binary, RethinkDB
SDB
SisoDB
scanned image. Terrastore
ThruDB
(www.nosql-database.org
www.db-engines.com
www.wikipedia.com)
12
MongoDB
• MongoDB is a document database designed for ease of development and
scaling.
• MongoDB offers both a Community and an Enterprise version of the database.
• 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.
The advantages of using document database are:
•Documents (i.e. objects) correspond to native data types in many programming
languages.
•Embedded documents and arrays reduce need for expensive joins.
•Dynamic schema supports fluent polymorphism.
13
Installing MongoDB
Go to:
www.mongo
db.com
Then go to
software ->
Community
Server
Then Click
Download
14
Installing Steps
• Run downloaded .msi file
• Install complete version
• Install MongoDB as service (by default)
• Keep data directory and log directory as it is
• Install MongoDB compass
• Wait for installation to finish.
1. Copy the path 2. Click environment variables 3. System variable 4. Add path 5. Add the
address (upto bin) 6. save this
2. A) Now go to C folder B) Create ‘data’ folder C) within data create ‘db’ folder
15
Run Command promt
Go to the bin folder
Open command prompt. Command is
mongod. It will start the mongo
demon
Open another command prompt.
Command is “mongo”. It will start
the mongo shell. Now you can write
programs of NoSQL.
Shell script will show “>” sign
16
Commands
Show Databases Lets create another
database named “another”
> Show dbs
Show databases
It will not show “another” as
no table or collection is
created
Create new database Insert a collection “Extra”
> Use database_name
Now show databases will
> Use bennett show “another”
Create collection
Here collection represents table For delete database use
>db.dropDatabase()
>db.createCollection(“table_name”)
Show the databases again
>db.createCollection(“testable”)
“another” database is
deleted
17
Commands
Go to the database
See all the collection
Presents using
>show collections
For delete
>db.collection_name.drop()
Insert 1 data into the collection/table
using “insertOne” operation
Insert many data into the collection
using “insertManyOne” operation
Db.tablename.insertMany([{ }, { }, { }])
18
Commands
Retrieve data
>db.table_name.find();
Select some particular value
>db.table_name.find({attribute: {$option: value}})
You can find details in the following website:
https://docs.mongodb.com/manual/tutorial/query-documents/
https://docs.mongodb.com/manual/reference/operator/query/
List of options available
19
Commands
Delete row
>db.table_name.deleteMany({attribute:value})
Again show the records
>db.table_name.find()
the record with the name “ABC” has been deleted.
Different types of
update options available
20
MapReduce Example
Source: https://docs.mongodb.com/manual/aggregation/
21
MapReduce Example
Create a database
Create collection “cust”
Use aggregate function. Take the data of “A” and sum the amount based on “id”
22
Reference
http://www.strozzi.it/cgi-bin/CSA/tw7/I/en_US/nosql/Home%20Page
Manual: https://docs.mongodb.com/manual