NoSQL Not Only SQL University of Kurdistan Faculty of Engineering Department of Computer & IT Engineering NoSQL Not Only SQL Asoo Mafakheri Moslem Parvizpour
Contents Introduction Comparison Challenges Property Application CAP Theorem Categories Implementation 2/2/2019 NoSQL
Introduction NOSQL stands for History Not only SQL No Relational No RDBMS Not Use SQL Carlo Strozzi Eric Evans History 1998: Carlo Strozzi 2000-2008: Neo4j ,… 2009: Eric Evans 2/2/2019 NoSQL
Popularity 2/2/2019 NoSQL
Question? NoSQL 2/2/2019 NoSQL
Challenges with traditional RDBMS Not optimized for horizontal scaling out Scalability Vertically (or Scale Up) Horizontally (or Scale Out) High velocity of data ingestion Schema-Less data Document database Cost ? 2/2/2019 NOSQL
Property Non Relational Schema Free Distributed Web Scale Design to store Volome Varied BASE Basically Available Soft State Eventually Consistent ACID Atomicity Consistency Isolation Durability 2/2/2019 NoSQL
Application × × Company SQL NOSQL Google BigTable, LevelDB Amazon Dynamo Facebook Cassandra Twitter HBase, FlockDB, Cassandra LinkedIn Voldemort Netflix SimpleDB, HBase, Cassandra Company SQL NOSQL Google × Amazon Facebook Twitter LinkedIn Netflix Company SQL NOSQL Google Amazon Facebook Twitter LinkedIn Netflix 2/2/2019 NoSQL
Question? 30% 70% SQL NoSQL 2/2/2019 NoSQL
CAP Theorem Availability Consistency Partition Tolerance Pick 2 همهی کاربران همیشه میتوانند درج کنند و بخوانند. دادههایی که نمایش داده میشوند، برای تمام کاربران یکسان میباشند. سیستم روی سرورهای مختلف در مکانهای جغرافیایی دور از هم کار میکند. Pick 2 2/2/2019 NoSQL
CAP Theorem A C P Pick 2 CA AP CP RDBMSs: Oracle, Postgre) (MySQL, SQL Server, Vertica AP Dynamo Voldemort Cassandra SimpleDB CouchDB Riak CP BigTable HyperTable HBase MongoDB Terrastore Redis Pick 2 2/2/2019 NoSQL
Categories DBMS SQL(Relational DBMS) NoSQL Key-value Document-Based Column-Based Graph-Based 2/2/2019 NoSQL
Categories NOSQL Flock DB Column Key-Value Document Graph Dynamo Voldemort Flock DB 2/2/2019 NoSQL
Categories NOSQL Graph Column Key-Value Document HyperTable Dynamo Neo4j Column HBase Key-Value Voldemort Dynamo Document CouchDB MongoDB NOSQL HyperTable Cassandra Redis FlockDB Riak name Ali email ali.rad@gmail.com Key Value age 68 OrientDB 2/2/2019 NoSQL
Categories NOSQL Graph Column Key-Value Document HyperTable Dynamo Neo4j Column HBase Key-Value Voldemort Dynamo Document CouchDB MongoDB NOSQL HyperTable Cassandra Redis FlockDB Riak <Document> { { "Title": "", "Author": "", "Date": “2012" } } Key OrientDB 2/2/2019 NoSQL
Comment 1 2 Title Articles 3 4 Relational Title 1 Comment Document 2/2/2019 NoSQL
Categories NOSQL Graph Column Key-Value Document Neo4j HBase Voldemort Dynamo Document CouchDB MongoDB NOSQL HyperTable Cassandra Redis FlockDB Riak 101 Name Age Reza 39 104 Email Name Tel ali.rad@gmail.com Ali +98-111-222-3333 OrientDB 2/2/2019 NoSQL
Categories NOSQL Graph Column Key-Value Document HyperTable Dynamo Neo4j Column HBase Key-Value Voldemort Dynamo Document CouchDB MongoDB NOSQL HyperTable Cassandra Redis FlockDB Riak OrientDB 2/2/2019 NoSQL
CAP Theorem A C P Pick 2 CA AP CP Data Models: RDBMSs: Oracle, Postgre) (MySQL, SQL Server, Vertica AP Dynamo Voldemort Cassandra SimpleDB CouchDB Riak CP BigTable HyperTable H Base MongoDB Terrastore Redis Pick 2 Data Models: Relational Key-Value Column-Oriented Document-Oriented 2/2/2019 NoSQL
CAP Theorem A C P Pick 2 CA AP CP Data Models: RDBMSs: Oracle, Postgre) (MySQL, SQL Server, Vertica AP Dynamo Voldemort Cassandra SimpleDB CouchDB Riak A Pick 2 C P CP BigTable HyperTable H Base MongoDB Terrastore Redis Data Models: Relational Key-Value Column-Oriented Document-Oriented 2/2/2019 NoSQL
Rated different categories Functionality Complexity Flexibility Scalability Performance Variable (none) none high Key-value minimal low moderate High Column Variable (low) Variable (high) Document Graph theory variable Graph Relational algebra Relational 2/2/2019 NoSQL
Question? Are you Google? What about Facebook? Do you have a social Graph? Are you twitter? Embedded? Bad Network? Device cluster? Is your data Structured? Do you need high Availability? Do you need Web Scale? No you don’t? RDBMS HBase Mongo Couch Riak FlockDB Neo4j Yes No 2/2/2019 NoSQL
ORM vs ODM Object-relational mapping (ORM) Converting data between Provide CRUD operation Object-document mapping (ODM) 2/2/2019 NoSQL
Differences RDBMS vs NoSQL (MongoDB) Data base >> Table,View Collection Row Document(BSON) Column Field Index Join Embedded Document Foreign Key Reference Partition Shard 2/2/2019 NoSQL
JSON JavaScript Object Notation (JSON) A lightweight text based data-interchange format Completely language independent A subset of JavaScript Not a document format Using for Data Modeling in NoSQL document-based databases CouchDB OrientDB MongoDB 2/2/2019 NoSQL
JSON JSON XML { "Book": { "Title": "A Man Called Ove", "Author": "Fredrik Backman", "Date": “2012" }, { "Title": "Der Engel schwieg", "Author": "Heinrich Böll", "Date": “1992" } } <books> <book> <title>A Man Called Ove</title> <author>Fredrik Backman</author> <date>2012</date> </book> <title>Der Engel schwieg</title> <author>Heinrich Böll</author> <date>1992</date> </books> 2/2/2019 NoSQL
CouchDB CouchDB is easy to use Document-Based HTTP-Based REST API Download from: http://couchdb.apache.org/ 2/2/2019 NoSQL
CouchDB Futon Control Panel http://localhost:5984/_utils/ HTTP: cURL 2/2/2019 NoSQL
cURL Command line tool for transferring data with URLs Supports: DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos), file transfer resume, proxy tunneling and more. 2/2/2019 NoSQL
cURL Flags -X Flag -H Flag -d Flag -O Flag 2/2/2019 NoSQL
HTTP Request Verbs POST - upload file GET - reads records PUT – creates & updates a record DELETE - deletes a record 2/2/2019 NoSQL
Create & Delete Database using cURL Hello CouchDB Creating a Database Deleting a Database List of All Databases curl http://127.0.0.1:5984/ curl -X PUT http://127.0.0.1:5984/database_name curl -X DELETE http://127.0.0.1:5984/database_name curl -X GET http://127.0.0.1:5984/_all_dbs 2/2/2019 NoSQL
Document CRUD using cURL Creating a Document: curl -X PUT http://127.0.0.1:5984/database_name/document_id -d ' { document} ' Get a Document: curl -X GET http://127.0.0.1:5984/database_name/document_id Updating Documents: curl -X PUT http://127.0.0.1:5984/database_name/document_id/ -d '{ "field" : "value", "_rev" : "revision id" } Deleting Documents: curl -X DELETE http://127.0.0.1:5984/database_name/database_id?_rev 2/2/2019 NoSQL
Attaching Files using cURL curl -vX PUT http://127.0.0.1:5984/database_name/database_id /filename?rev=document rev_id --data-binary @filename -H "Content-Type:type of the content" 2/2/2019 NoSQL
Reference 2/2/2019 NoSQL
Thank You