Slide 1

Slide 1 text

NoSQL Shuaib Afegbua, forloop + Abuja developers Meetup Enspire Incubator, Maitama

Slide 2

Slide 2 text

Shuaib Afegbua. Recovering software developer. Day Job: Information Systems Specialist @ Cambridge Education. Night Job: Chief Hacker, Code Kraft Twitter: @afegbuas

Slide 3

Slide 3 text

Content ● What is NoSQL? ● Why NoSQL? ● Types of NoSQL database ● Example use cases ● Data modelling ● Explanation - sharding, replication, aggregation, performance, security ● The SQL vs NoSQL myth ● When to use NoSQL ● Resource and References

Slide 4

Slide 4 text

OK! What is NoSQL? - Not Only SQL - Generally refers to ‘anything’ outside the relational database paradigm - Gained traction in about 2006 with increase in volume of data think Amazon,Google, facebook

Slide 5

Slide 5 text

SO! Now compare to before? Imagine the first release commercial of RDBMS - Oracle 1979. WTF! Shift towards digital economy powered by internet Large numbers of concurrent users Increase in volume of data IoT – internet is connecting everything Cloud based system Everything is going mobile

Slide 6

Slide 6 text

SQL DATABASES ● Tabular and structured storage ● Pre defined schema ● Use Joins to retrieve related data ● Difficult and expensive to scale - scale vertically/up ● Atomic transaction ● Encourages normalisation of data ● Enforce data integrity rules

Slide 7

Slide 7 text

SQL DBs - tabular structure. Photo credits: couchbase

Slide 8

Slide 8 text

SQL DB - tabular structure. Photo credits: couchbase

Slide 9

Slide 9 text

NoSQL DATABASES ● JSON like storage, graphs, key-value pairs ● Flexible/dynamic schema ● Embedded documents over relationship/normalised data ● Easy - scale horizontal/out ● No Guarantee on Atomic transaction ● Distributed ● Mostly Open Source

Slide 10

Slide 10 text

NoSQL DBs

Slide 11

Slide 11 text

SO! Why NoSQL? ★ Handling huge volume of changing data ★ Need for Agile development sprints and multiple iteration ★ Operational Issues and Scaling - Scaling out architecture instead of expensive, monolithic architecture ★ Speed and the need to have 24x7 availability

Slide 12

Slide 12 text

1 Agile development sprints Photo credits: couchbase

Slide 13

Slide 13 text

1 Agile development sprints Photo credits: couchbase

Slide 14

Slide 14 text

3 Operational scaling Photo credits: couchbase

Slide 15

Slide 15 text

3 Operational scaling Scaling out gives these benefits (a) deploying no more hardware than is required to meet the current load (b) leveraging less expensive hardware and/or cloud infrastructure; and (c) scaling on-demand and without downtime. Source: couchbase

Slide 16

Slide 16 text

4 Handling huge volume of changing data ● 2.5 quintillion bytes of data daily (2.5 x 1018 or 2 trillion million) => 10 million blu-ray disc ● Past 3 years has accounted for over 90% ● Mostly unstructured and semi structured

Slide 17

Slide 17 text

5 24x7 availability needs single server/or as a cluster and the shared storage failure Photo credits: couchbase

Slide 18

Slide 18 text

5 24x7 availability needs single server/or as a cluster and the shared storage failure Photo credits: couchbase

Slide 19

Slide 19 text

6 Replication Built-in and easy replication features. RDBMS VS NOSQL

Slide 20

Slide 20 text

Who uses NoSQL ● ME - CouchDB, MongoDB and falling in love OrientDB ● Amazon - Dynamodb ● Google - Big Table ● Ebay/ US National Archives - Mongo ● Facebook/Instagram/Apple/Netflix - Cassandra ● Paypal/verizon/Tesco ● Airbus - Oracle NoSQL ● Twitter - Flockdb

Slide 21

Slide 21 text

Categories of NoSQL DBs Key-Value store Document oriented Graph Database Wide column Redis Memcached RocksDB CouchDB Couchbase MongoDB OrientDB RethinkDB RavenDB Neo4J OrientDB BrightstarDB FlockBD Cassandra Habase Amazon SimpleDB DynamoDB - Multi Model Databases: OrientDB, ArangoDB etc - Special cases: Embedded (PouchDB $ LokiJs and Object databases (ObjectDB) Source: http://nosql-database.org

Slide 22

Slide 22 text

How do you model and query your data? Schema-less? Idiomatic? Thrift/REST API? Relationships? References? SQL-like?

Slide 23

Slide 23 text

Key-Value Stores Probably the simplest and most basic type. Store pairs of keys and values, as well as retrieve values when a key is known Speed Most in memory

Slide 24

Slide 24 text

Redis - Key-Value Store “Redis is an open source, in-memory Data Structure Store, used as a database, a caching layer or a message broker.” - Redis website ● Extremely fast ● Strings or list storage ● Persistence instead of memory ● Replication ● Multiple language clients ● Supports transactions but no rollback Use cases: Cache systems, Queue, recent listing etc.

Slide 25

Slide 25 text

Redis - resource https:/redis.io Redis labs - redislabs.com Building NoSQL Apps With Redis - https://www.pluralsight.com/courses/building-nosql- apps-redis Internet search/Youtube

Slide 26

Slide 26 text

Document Oriented Stores data in JSON-like structures called documents Image credits: mongodb

Slide 27

Slide 27 text

SQL to Mongo Mapping Chart SQL MongoDB database database table collection row document column field index index joins embedded/linking aggregation (e.g. group by) aggregation pipeline

Slide 28

Slide 28 text

Mongodb - Resource https://docs.mongodb.org/manual/ Mongo University - http://university.mongodb.com/ Internet search/Youtube Robomongo - http://robomongo.com

Slide 29

Slide 29 text

CouchDB - brief overview REST API Single document tant Simple and easy to use Super replication Low latency

Slide 30

Slide 30 text

OrientDB - Graph databases Both document oriented and graph Dynamic schema Extended SQl syntax Inheritance and polymorphism Language API and REST

Slide 31

Slide 31 text

Graph databases Stores data as nodes/vertex connected with edges/links Image credits: OrientDB

Slide 32

Slide 32 text

OrientDB - Graph databases Stores data as nodes/vertex connected with links Both document oriented and graph Dynamic schema and extended SQl syntax Inheritance and polymorphism Language API and REST Multi-master Replication

Slide 33

Slide 33 text

key elements - OrientDB Image credits: OrientDB

Slide 34

Slide 34 text

key elements - OrientDB Image credits: OrientDB

Slide 35

Slide 35 text

key elements - OrientDB Image credits: OrientDB

Slide 36

Slide 36 text

vertex/node - Graph DB

Slide 37

Slide 37 text

Edge/Link - Graph DB Image credits: OrientDB

Slide 38

Slide 38 text

class - Graph DB Image credits: OrientDB

Slide 39

Slide 39 text

OrientDB Studio - Graph DB Image credits: OrientDB

Slide 40

Slide 40 text

Resources ● www.orientdb.com ● https://www.udemy.com/orientdb-getting-started ● www.neo4j.com

Slide 41

Slide 41 text

Wide Column - Cassandra ● Columns are created for each row rather than being predefined by the table structure ● Column Families => RDBMS Table/Keyspace => Database

Slide 42

Slide 42 text

Wide Column oriented 1. Extremely powerful 2. Highly scalable 3. More of advanced key-value storage 4. Handle huge amount of information. 5. Increased granularity – being able to update an individual column 6. Cassandra uses SQL-like -> CQL

Slide 43

Slide 43 text

Column oriented - Resource ● CASSANDRA - planetcassandra.com ● http://cassandra.apache.org/ ● Internet search/Youtube -> wide Column database ● https://hbase.apache.org/ ● https://academy.datastax.com/

Slide 44

Slide 44 text

So which is better? The SQL vs NoSQL Myth?

Slide 45

Slide 45 text

The SQL vs NoSQL Myth ● Supersedes and better ● They are opposite of the same coin ● The language/framework determines the database most times

Slide 46

Slide 46 text

SO WHEN SHOULD I USE NoSQL? Photo credit: Rocnation

Slide 47

Slide 47 text

Choosing NoSQL ● Mobile backends ● Internet of things ● Single view/360 customer view situation ● Content Management ● Fraud Detection

Slide 48

Slide 48 text

Choosing NoSQL ● Profile management ● catalog ● Caching and Queueing ● Real-Time Analytics ● Social networks

Slide 49

Slide 49 text

NoSQL Databases will evolve and get better. But they are suitable for ’specific cases’. NoSQL != Replace(SQL DB)

Slide 50

Slide 50 text

Well! POSTGRES is the greatest This is a highly opinionated view from an aspiring SENIOR PROGRAMMER. NoSQL databases have their places and specific use cases.

Slide 51

Slide 51 text

Resources ● nosql-database.org ● redis.io ● https://university.mongodb.com ● orientdb.com ● http://couchdb.apache.org ● http://cassandra.apache.org

Slide 52

Slide 52 text

THANK YOU YOU GOT PROBLEMS CALL THE ARROW => [email protected] Twitter: @afegbuas Photo credit: HBO

Slide 53

Slide 53 text

Thank you! [email protected] Twitter: @afegbuas