University of Kurdistan Faculty of Engineering Department of

  • Slides: 36
Download presentation
University of Kurdistan Faculty of Engineering Department of Computer & IT Engineering No. SQL

University of Kurdistan Faculty of Engineering Department of Computer & IT Engineering No. SQL Not Only SQL Asoo Mafakheri Moslem Parvizpour

Contents • Introduction • Comparison • Challenges • Property • Application • CAP Theorem

Contents • Introduction • Comparison • Challenges • Property • Application • CAP Theorem • Categories • Implementation 3/12/2021 No. SQL 2

Introduction NOSQL stands for • • Not only SQL No Relational No RDBMS Not

Introduction NOSQL stands for • • Not only SQL No Relational No RDBMS Not Use SQL History • 1998: Carlo Strozzi • 2000 -2008: Neo 4 j , … • 2009: Eric Evans Carlo Strozzi 3/12/2021 No. SQL Eric Evans 3

Popularity DB-Engines Ranking 3/12/2021 Oracle (RDBMS) My. SQL (RDBMS) SQL Server (RDBMS) Postgre. SQL

Popularity DB-Engines Ranking 3/12/2021 Oracle (RDBMS) My. SQL (RDBMS) SQL Server (RDBMS) Postgre. SQL (RDBMS) Mongo. DB (Document Store) Redis (Key-Value) Elasticsearch (Search Engine) Cassandra (Column Store) Splunk (Search Engine) HBase (Column-Store) Neo 4 j (Graph DBMS) Couch. DB (Document Store) Orient. DB (Graph, Key, Doc) Level. DB (Key-Value) No. SQL 4

Question? No. SQL 3/12/2021 No. SQL 5

Question? No. SQL 3/12/2021 No. SQL 5

Challenges with traditional RDBMS • Not optimized for horizontal scaling out • Scalability Basic

Challenges with traditional RDBMS • Not optimized for horizontal scaling out • Scalability Basic Insert Operation • Vertically (or Scale Up) • Horizontally (or Scale Out) • Document database • Cost 160 140 120 Seconds • High velocity of data ingestion • Schema-Less data 180 SQL Mongo 100 80 60 ? 40 20 0 100 5000 250000 Row Insert 3/12/2021 NOSQL 6

Property • Non Relational • Schema Free • Distributed • Web Scale • Design

Property • Non Relational • Schema Free • Distributed • Web Scale • Design to store • BASE • Basically Available • Soft State • Eventually Consistent • ACID • • • Volome • Varied 3/12/2021 No. SQL Atomicity Consistency Isolation Durability 7

Application 3/12/2021 Company SQL NOSQL Google × Big. Table, Level. DB Amazon × Dynamo

Application 3/12/2021 Company SQL NOSQL Google × Big. Table, Level. DB Amazon × Dynamo Facebook × Cassandra Twitter × HBase, Flock. DB, Cassandra Linked. In × Voldemort Netflix × Simple. DB, HBase, Cassandra SQL No. SQL 8

Question? No. SQL 30% SQL 70% 3/12/2021 No. SQL 9

Question? No. SQL 30% SQL 70% 3/12/2021 No. SQL 9

CAP Theorem A CA RDBMSs: Oracle, Postgre) AP (My. SQL, SQL Server, Vertica Pick

CAP Theorem A CA RDBMSs: Oracle, Postgre) AP (My. SQL, SQL Server, Vertica Pick 2 C 3/12/2021 Simple. DB Couch. DB Riak P CP Big. Table Hyper. Table HBase Dynamo Voldemort Cassandra Mongo. DB Terrastore Redis No. SQL 11

Categories DBMS • SQL(Relational DBMS) • No. SQL • Key-value • Document-Based • Column-Based

Categories DBMS • SQL(Relational DBMS) • No. SQL • Key-value • Document-Based • Column-Based • Graph-Based 3/12/2021 No. SQL 12

Categories Dynamo Voldemort Key-Value Column NOSQL Graph Document B D k c Flo 3/12/2021

Categories Dynamo Voldemort Key-Value Column NOSQL Graph Document B D k c Flo 3/12/2021 No. SQL 13

Categories Hyper. Table Cassandra Key name email age 3/12/2021 HBase Voldemort NOSQL Flock. DB

Categories Hyper. Table Cassandra Key name email age 3/12/2021 HBase Voldemort NOSQL Flock. DB Ali Graph Document ali. rad@gmail. com Neo 4 j 68 Orient. DB Redis Key-Value Column Value Dynamo Riak Couch. DB Mongo. DB No. SQL 14

Categories Key <Document> { } Hyper. Table {Cassandra "Title": "", "Author": "", "Date": “

Categories Key <Document> { } Hyper. Table {Cassandra "Title": "", "Author": "", "Date": “ 2012" } HBase Voldemort NOSQL Graph Orient. DB Redis Key-Value Column Flock. DB Neo 4 j Dynamo Document Riak Couch. DB Mongo. DB 3/12/2021 No. SQL 15

Relational Articles Comment 1 Title 1 Comment 1 2 Title 2 Comment 1 3

Relational Articles Comment 1 Title 1 Comment 1 2 Title 2 Comment 1 3 Comment 1 4 Comment 2 Document 1 Title Comment 1 3/12/2021 No. SQL Title Comment 16

Categories Hyper. Table Cassandra 101 104 Name Flock. DB Age Reza 39 Email. Neo

Categories Hyper. Table Cassandra 101 104 Name Flock. DB Age Reza 39 Email. Neo 4 j ali. rad@gmail. com 3/12/2021 HBase Dynamo Redis Key-Value Column Voldemort NOSQL Graph Document Name Tel Couch. DB Orient. DB Ali +98 -111 -222 -3333 No. SQL Riak Mongo. DB 17

Categories Hyper. Table Cassandra HBase Voldemort NOSQL Graph Orient. DB Redis Key-Value Column Flock.

Categories Hyper. Table Cassandra HBase Voldemort NOSQL Graph Orient. DB Redis Key-Value Column Flock. DB Neo 4 j Dynamo Document Riak Couch. DB Mongo. DB 3/12/2021 No. SQL 18

CAP Theorem A CA RDBMSs: Oracle, Postgre) AP (My. SQL, SQL Server, Vertica Pick

CAP Theorem A CA RDBMSs: Oracle, Postgre) AP (My. SQL, SQL Server, Vertica Pick 2 C 3/12/2021 P CP Big. Table Hyper. Table H Base Dynamo Voldemort Cassandra Mongo. DB Terrastore Redis No. SQL Simple. DB Couch. DB Riak Data Models: v v Relational Key-Value Column-Oriented Document-Oriented 19

CAP Theorem CA RDBMSs: Oracle, Postgre) (My. SQL, SQL Server, Vertica A Dynamo Voldemort

CAP Theorem CA RDBMSs: Oracle, Postgre) (My. SQL, SQL Server, Vertica A Dynamo Voldemort Cassandra AP Simple. DB Couch. DB Riak Pick 2 P C CP Big. Table Hyper. Table H Base 3/12/2021 Data Models: Mongo. DB Terrastore Redis No. SQL v v Relational Key-Value Column-Oriented Document-Oriented 20

Rated different categories Performance Scalability Flexibility Complexity Functionality Key-value high none Variable (none) Column

Rated different categories Performance Scalability Flexibility Complexity Functionality Key-value high none Variable (none) Column High high moderate low minimal Document high Variable (high) high low Variable (low) Graph variable high Graph theory Relational variable low moderate Relational algebra 3/12/2021 No. SQL 21

Question? Are you Google? Yes No What about Facebook? HBase Flock. DB Yes No

Question? Are you Google? Yes No What about Facebook? HBase Flock. DB Yes No Yes Do you have a social Graph? Yes Neo 4 j Riak No No Do you need high Availability? 3/12/2021 No No. SQL RDBMS No Embedded? Bad Network? Device cluster? Are you twitter? Mongo Yes No Couch Is your data Structured? Yes No you don’t? Yes Do you need Web Scale? No 22

ORM vs ODM • Object-relational mapping (ORM) • Converting data between • Provide CRUD

ORM vs ODM • Object-relational mapping (ORM) • Converting data between • Provide CRUD operation • Object-document mapping (ODM) 3/12/2021 No. SQL 23

Differences 3/12/2021 RDBMS vs No. SQL (Mongo. DB) Data base >> Data base Table,

Differences 3/12/2021 RDBMS vs No. SQL (Mongo. DB) Data base >> Data base Table, View >> Collection Row >> Document(BSON) Column >> Field Index >> Index Join >> Embedded Document Foreign Key >> Reference Partition >> Shard No. SQL 24

JSON • Java. Script Object Notation (JSON) • • • A lightweight text based

JSON • Java. Script Object Notation (JSON) • • • A lightweight text based data-interchange format Completely language independent A subset of Java. Script Not a document format Using for Data Modeling in No. SQL document-based databases • Couch. DB • Orient. DB • Mongo. DB 3/12/2021 No. SQL 25

JSON { } XML JSON <books> <book> <title>A Man Called Ove</title> <author>Fredrik Backman</author> <date>2012</date>

JSON { } XML JSON <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> "Book": { "Title": "A Man Called Ove", "Author": "Fredrik Backman", "Date": “ 2012" }, { "Title": "Der Engel schwieg", "Author": "Heinrich Böll", "Date": “ 1992" } 3/12/2021 No. SQL 26

Couch. DB • • 3/12/2021 Couch. DB is easy to use Document-Based HTTP-Based REST

Couch. DB • • 3/12/2021 Couch. DB is easy to use Document-Based HTTP-Based REST API Download from: http: //couchdb. apache. org/ No. SQL 27

Couch. DB Futon Control Panel http: //localhost: 5984/_utils/ 3/12/2021 HTTP: c. URL No. SQL

Couch. DB Futon Control Panel http: //localhost: 5984/_utils/ 3/12/2021 HTTP: c. URL No. SQL 28

c. URL Command line tool for transferring data with URLs Supports: DICT, FILE, FTPS,

c. URL Command line tool for transferring data with URLs Supports: DICT, FILE, FTPS, Gopher, HTTPS, IMAPS, LDAPS, POP 3 S, RTMP, RTSP, SCP, SFTP, SMBS, 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-MD 5, NTLM, Negotiate and Kerberos), file transfer resume, proxy tunneling and more. 3/12/2021 No. SQL 29

c. URL Flags • -X Flag • -H Flag • -d Flag • -O

c. URL Flags • -X Flag • -H Flag • -d Flag • -O Flag 3/12/2021 No. SQL 30

HTTP Request Verbs • POST - upload file • GET - reads records •

HTTP Request Verbs • POST - upload file • GET - reads records • PUT – creates & updates a record • DELETE - deletes a record 3/12/2021 No. SQL 31

Create & Delete Database using c. URL • Hello Couch. DB • Creating a

Create & Delete Database using c. URL • Hello Couch. DB • Creating a Database • Deleting a Database • List of All Databases 3/12/2021 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 No. SQL 32

Document CRUD using c. URL Creating a Document: curl -X PUT http: //127. 0.

Document CRUD using c. URL 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 3/12/2021 No. SQL 33

Attaching Files using c. URL curl -v. X PUT http: //127. 0. 0. 1:

Attaching Files using c. URL curl -v. X 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" 3/12/2021 No. SQL 34

Reference 3/12/2021 No. SQL 35

Reference 3/12/2021 No. SQL 35

Thank You

Thank You