# NoSQL

### Objectives :

* Understand what does NoSQL mean
* Understand the different kind of databases hidden behind this word

## Connection - 10'

* In pair list every Pros and Cons you have encountered with relational database
* List every relational database you have already used
* Group the answers

## Concepts - 20'

### Relational databases

* Persist data
* Concurrency control
* Manage transactions in an ACID way

### ACID

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAffO8xa1ZWmgZvfeK2%2F-MRsSsqFo_JqSr2fslcx%2F-MRsVOKv4VVy9VD8mwOJ%2Fimage.png?alt=media\&token=1a8bd4d8-02dc-4d3d-8b29-65b9ace351d9)

* Atomicity
  * "all or nothing"
  * One part fails => the entire transaction fails
* Consistency
  * Bring the database from one valid state to another
  * All defined rules, including constraints, cascades, triggers, and any combination are respected
* Isolation
  * Concurrent execution
    * Would be obtained if transactions were executed sequentially
* Durability
  * Transaction committed : it will remain

### Cons of relational databases

* Impedance mismatch
  * Relational data structures vs In-memory data structures
* Performance
* Distribution
* Cost

### NoSQL

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAffO8xa1ZWmgZvfeK2%2F-MRsVuTVyJ6UbEaSg0im%2F-MRsW0tO6L3-zetIjU0w%2Fimage.png?alt=media\&token=5a1db134-f58e-4448-bbbe-95156f324ba1)

### Different kind of NoSQL Databases

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAffO8xa1ZWmgZvfeK2%2F-MRsVuTVyJ6UbEaSg0im%2F-MRsW75xGBqkiacPMQlL%2Fimage.png?alt=media\&token=f82f7b01-6888-4837-8591-5d745a72ddb0)

### Why use NoSQL ?

* To improve programmer productivity : better matches an application needs&#x20;
* To improve data access performance&#x20;
  * Through some combination of handling larger data volumes, reducing latency&#x20;
* Large volumes of rapidly changing structured, semi-structured, and unstructured data
* Geographically distributed scale-out architecture&#x20;
  * Instead of expensive, monolithic architecture

## Concrete Practice - 20'

Let's play with a GraphDB call Neo4j for the next minutes :

* Connect to the [platform](https://sandbox.neo4j.com/)
* Play with the Cypher queries
* Play with the Graph Visualization

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAffO8xa1ZWmgZvfeK2%2F-MRsWUeRgjpevuUMJxhG%2F-MRsXu6hH4Y2YYI816NK%2Fimage.png?alt=media\&token=a3129493-931a-4749-82bf-79605b41d47c)

## Conclusion - 10'

{% hint style="success" %}
***NoSQL does not mean “Death of SQL”***
{% endhint %}

We can now create polyglot persistence :

* Uses different data storage technologies to handle varying data storage needs
* Can be applied : Anywhere in an organization/in a single application

Use the tool that fits the best your needs.

![](https://1936518372-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAffO8xa1ZWmgZvfeK2%2F-MRsYBPAkSaGlwyvzJb7%2F-MRsYGMOP7oIzNpVLUdv%2Fimage.png?alt=media\&token=f52fde48-9edf-4766-8836-c09a2ce27848)

### Remember the past

Think about the past few years, in which development you have made this kind of database would have been useful ?

* Why ?

### Resources

#### Key Value Stores

* Aerospike
* Apache Cassandra
* Berkeley DB
* Couchbase Server
* Redis
* Riak

#### Document DB

* CouchDB
* Elasticsearch
* MongoDB

#### Graph DB

* Neo4j
* OrientDB
* FlockDB

#### Wide Columns Family Stores

* Cassandra
* HBase
