SlideShare ist ein Scribd-Unternehmen logo
1 von 32
MongoDB
ElasticSearch
Couchbase
Prepared by: Shalkarbayuly A. (PhD student)
Presentation was prepared for “Database Management” course as
a part of PhD program in Turgut Ozal University
1. NoSQL databases
2. MongoDB
3. ElasticSearch
4. Couchbase
What is NoSQL?
NoSQL databases
NOSQL sometimes stands for Not Only SQL
NOSQL is mechanism for storage and retrieval
of data other than tabular data
Motivations are simplicity of design, horizontal
scaling, control over availability
Problems of RD solved by NoSQL
★ RD will not scale to your traffic at an
acceptable cost
★ NoSQL provides a tool to develop new
features easily.
★ NoSQL have local data transactions which
do not have to be very durable. e.g. “liking”
items on websites.
Avoid NoSQL
➢If application requires run-time flexibility.
➢If application requires ACID
➢if application requires complicated queries
➢if application requires query language
➢If consistency is mandatory and there will
be no drastic changes in data volume,
relational databases would be a better option
What is MongoDB?
★ MongoDB is cross-platform
★ MongoDB is document-oriented database
★ MongoDB is a NoSQL database
★ MongoDB stores data in JSON-like
documents
MongoDB philosophy
Keep functionality when we can
Non-relational makes scaling horizontally
practical
Document models are good
Database technology should run anywhere
VMs, cloud, metal, etc
Use cases for MongoDB
Need of horizontal scaling:
storing in many regular servers
Iterative development:
regular changes of database’s structure
Document-oriented logic:
web page is important than data
Functionality vs Scalability & Performance
Goal: create Web-application for e-commerce
Products: there is no specific products, different
type of products may be sold on webapp
Problem: design database schema
E-commerce: sample problem
Product_Book{
id, name, shipping_info,
price, description,
……….
author,
title,
publisher,
edition,
ISBN
}
Product_Media{
id, name, shipping_info,
price, description,
……….
artist,
title,
track_listing,
label,
format
}
Simple solution: each time create table for specific product type
Problem: very complex code, creating table, rewriting app takes time and
causes errors, items cannot be considered as one item
RELATIONALDATABASE
approach
Product{
id, name, shipping_info,
price, description,
field1_value,
field1_name,
field2_value,
field2_name,
}
Product{
id, name, shipping_info,
price, description,
type,
author,
artist,
track_listing,
ISBN,
}
Set of fields with value and name
Problems: what if there are many
fields, how to find all books
All types of attributes in one table
Problems: new items causes
changes in code and table
RELATIONALDATABASE
approach
Book{
title,
author,
ISBN,
}
Product{
id, name, shipping_info,
price, description,
type (whether book or
media)
}
Creating polymorphic tables
Problems: need extra JOINS, which causes increase of speed
RELATIONALDATABASE
approach
MongoDB rescues
★ Flexible schema
★ Easily searchable
★ Easily accessible
★ Fast
{title: “Matrix”, price: 3500,
details:{actors:[‘Keanu Reaves’,’’K. Zeta Jones’]}}
{title: “Sherlock Holmes”, price: 2100,
details:{ISBN:33002A,author:”Conan Doyle”}}
★ MongoDB stores data in document form
○ Don’t need schema
○ Store in JSON form
○ Datas are edited in application
★ No JOINS
○ Data is loaded in LINEAR time
CRUD operations
Retrieving, creating, updating, deleting operations are done
on application side
There is no SQL queries
if software has many apps (on different platforms) it is BAD.
Because you have to write logic each time
if software has one app it is GOOD.
Because you don’t have to mess with SQL code
MongoDB: java example
//Create
String json = “{‘name’:’Mike’,’surname’:’Smith’}”;
DBObject dbObject = (DBObject)JSON.parse(json);
collection.insert(dbObject);
//Retrieve
db.products.find({‘title’:”The Matrix”});
//Update
BasicDBObject newD = new BasicDBObject();
newD.append("$set",new BasicDBObject().append("clients", 110));
BasicDBObject sq = new BasicDBObject().append("name", "Mike");
collection.update(sq, newD);
ElasticSearch
★ Real-time data
★ Real-time analytics
★ Distributed
★ High-availability
★ Multitenancy
★ Full-text search
★ Document-oriented
★ Schema-free
★ RESTful API
★ Build on top
Apache Lucene
Elasticsearch: important features
Elasticsearch is based on Lucene
Elasticsearch is ready for search of all types
➔Elasticsearch is search engine
➔Elasticsearch is document database
What is Lucene? (small explanation)
Lucene is information retrieval library, which
takes documents and makes them easily
searchable, through:
● indexing
● advanced analysis
● tokenization (indexing mice as mouse)
Lucene creates inverted
index, so that searching in
documents is performed in
linear time
Indexing
Searching terms in
documents without
indexing is
doc.size x no.documents
Don’t do this
Elasticsearch: use case
Elasticsearch is used as:
★ search engines
★ as a search mechanism for web-apps
among main database
○ e.g. E-commerce storing data in MongoDB, while
search data is stored in elasticsearch
★ as a document database
Elasticsearch: REST
Elasticsearch can be
accessed through
REST protocol
#Inserting data
PUT http://localhost:9200/movies/movie/1
{"title": "The Godfather","director":
"Francis Ford Coppola"}
#Getting data
GET http://localhost:9200/movies/movie/1
#Delete data
DELETE http://localhost:90/movies/movie/1
#Searching data
POST http://localhost:9200/_search
"query": {
"query_string": {
"query": "kill"
}
}
Couchbase
Couchbase history
Couchbase was created by combining two
NoSQL databases
Membase + CouchOne (principal players
behind CouchDB) = Couchbase
CouchBase
● Written in: Erlang & C
● Main point: Memcache compatible, but with
persistence and clustering
● Protocol: memcached + extensions
● Very fast (200k+/sec) access of data by key
● Provides memcached-style in-memory
caching buckets
Couchbase
Best used: Any application where low-latency
data access, high concurrency support and
high availability is a requirement.
For example: Low-latency use-cases like ad
targeting or highly-concurrent web apps like
online gaming (e.g. Zynga).
Couchbase
Couchbase store data in key-value or in document form
Couchbase is a key-value store: every Document has a
Key and a Value
Key can be a up to 250 characters
Keys are unique, within a bucket there can be only one key
Values can be JSON, string, numbers, binary blobs, special
positive number
Key-value NOSQL databases
Performance: high
Scalability: high
Flexibility: high
Complexity: none
Advantage:
High speed of response
Disadvantage:
All logic is located in app
Couchbase java example
CouchbaseClient c = new CouchbaseClient(baseURI, "default", "");
long userCounter = c.incr(“user_counter”,1,1);
c.set(“user:”+userCounter,json.toJson(user));
c.set("key", 0, "Hello World");
System.out.println(c.get("key"));

Weitere ähnliche Inhalte

Was ist angesagt?

Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Andrii Vozniuk
 
Log analysis with the elk stack
Log analysis with the elk stackLog analysis with the elk stack
Log analysis with the elk stack
Vikrant Chauhan
 

Was ist angesagt? (19)

Elasticsearch Arcihtecture & What's New in Version 5
Elasticsearch Arcihtecture & What's New in Version 5Elasticsearch Arcihtecture & What's New in Version 5
Elasticsearch Arcihtecture & What's New in Version 5
 
ELK - Stack - Munich .net UG
ELK - Stack - Munich .net UGELK - Stack - Munich .net UG
ELK - Stack - Munich .net UG
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELK
 
quick intro to elastic search
quick intro to elastic search quick intro to elastic search
quick intro to elastic search
 
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
 
Log analysis using Logstash,ElasticSearch and Kibana
Log analysis using Logstash,ElasticSearch and KibanaLog analysis using Logstash,ElasticSearch and Kibana
Log analysis using Logstash,ElasticSearch and Kibana
 
Elastic Stack Introduction
Elastic Stack IntroductionElastic Stack Introduction
Elastic Stack Introduction
 
The Ultimate Logging Architecture - You KNOW you want it!
The Ultimate Logging Architecture - You KNOW you want it!The Ultimate Logging Architecture - You KNOW you want it!
The Ultimate Logging Architecture - You KNOW you want it!
 
Intro to elasticsearch
Intro to elasticsearchIntro to elasticsearch
Intro to elasticsearch
 
Deep Dive on ArangoDB
Deep Dive on ArangoDBDeep Dive on ArangoDB
Deep Dive on ArangoDB
 
Elastic stack Presentation
Elastic stack PresentationElastic stack Presentation
Elastic stack Presentation
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Fluentd and Docker - running fluentd within a docker container
Fluentd and Docker - running fluentd within a docker containerFluentd and Docker - running fluentd within a docker container
Fluentd and Docker - running fluentd within a docker container
 
Big Data Overview Part 1
Big Data Overview Part 1Big Data Overview Part 1
Big Data Overview Part 1
 
Elastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & KibanaElastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & Kibana
 
tdtechtalk20160330johan
tdtechtalk20160330johantdtechtalk20160330johan
tdtechtalk20160330johan
 
Log analysis with the elk stack
Log analysis with the elk stackLog analysis with the elk stack
Log analysis with the elk stack
 
Presto Meetup 2016 Small Start
Presto Meetup 2016 Small StartPresto Meetup 2016 Small Start
Presto Meetup 2016 Small Start
 
Log analytics with ELK stack
Log analytics with ELK stackLog analytics with ELK stack
Log analytics with ELK stack
 

Andere mochten auch

Benchmarking MongoDB and CouchBase
Benchmarking MongoDB and CouchBaseBenchmarking MongoDB and CouchBase
Benchmarking MongoDB and CouchBase
Christopher Choi
 

Andere mochten auch (17)

Methods of NoSQL database systems benchmarking
Methods of NoSQL database systems benchmarkingMethods of NoSQL database systems benchmarking
Methods of NoSQL database systems benchmarking
 
Benchmarking MongoDB and CouchBase
Benchmarking MongoDB and CouchBaseBenchmarking MongoDB and CouchBase
Benchmarking MongoDB and CouchBase
 
PPC for ecommerce websites
PPC for ecommerce websitesPPC for ecommerce websites
PPC for ecommerce websites
 
UX mockups for an advanced search
UX mockups for an advanced searchUX mockups for an advanced search
UX mockups for an advanced search
 
Improving UX checkout
Improving UX checkoutImproving UX checkout
Improving UX checkout
 
Maximizing ROI in eCommerce with Search
Maximizing ROI in eCommerce with SearchMaximizing ROI in eCommerce with Search
Maximizing ROI in eCommerce with Search
 
UX: internal search for e-commerce
UX: internal search for e-commerceUX: internal search for e-commerce
UX: internal search for e-commerce
 
Data Science and Machine Learning for eCommerce and Retail
Data Science and Machine Learning for eCommerce and RetailData Science and Machine Learning for eCommerce and Retail
Data Science and Machine Learning for eCommerce and Retail
 
Machine Learning for retail and ecommerce
Machine Learning for retail and ecommerceMachine Learning for retail and ecommerce
Machine Learning for retail and ecommerce
 
NoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learnedNoSQL into E-Commerce: lessons learned
NoSQL into E-Commerce: lessons learned
 
Intro to Elasticsearch
Intro to ElasticsearchIntro to Elasticsearch
Intro to Elasticsearch
 
Webinar: OpenNLP and Solr for Superior Relevance
Webinar: OpenNLP and Solr for Superior RelevanceWebinar: OpenNLP and Solr for Superior Relevance
Webinar: OpenNLP and Solr for Superior Relevance
 
Tuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for LogsTuning Elasticsearch Indexing Pipeline for Logs
Tuning Elasticsearch Indexing Pipeline for Logs
 
E commerce search strategies how faceted navigation and apache solr lucene op...
E commerce search strategies how faceted navigation and apache solr lucene op...E commerce search strategies how faceted navigation and apache solr lucene op...
E commerce search strategies how faceted navigation and apache solr lucene op...
 
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusinessSurprising failure factors when implementing eCommerce and Omnichannel eBusiness
Surprising failure factors when implementing eCommerce and Omnichannel eBusiness
 
Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)Magento scalability from the trenches (Meet Magento Sweden 2016)
Magento scalability from the trenches (Meet Magento Sweden 2016)
 
Omnichannel Customer Experience
Omnichannel Customer ExperienceOmnichannel Customer Experience
Omnichannel Customer Experience
 

Ähnlich wie Presentation: mongo db & elasticsearch & membase

mongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputingmongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputing
moeincanada007
 

Ähnlich wie Presentation: mongo db & elasticsearch & membase (20)

Introducción a NoSQL
Introducción a NoSQLIntroducción a NoSQL
Introducción a NoSQL
 
Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorial
 
No sql databases
No sql databasesNo sql databases
No sql databases
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
 
NoSQL Databases
NoSQL DatabasesNoSQL Databases
NoSQL Databases
 
No sq lv1_0
No sq lv1_0No sq lv1_0
No sq lv1_0
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document database
 
Elasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparisonElasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparison
 
MongoDB NoSQL database a deep dive -MyWhitePaper
MongoDB  NoSQL database a deep dive -MyWhitePaperMongoDB  NoSQL database a deep dive -MyWhitePaper
MongoDB NoSQL database a deep dive -MyWhitePaper
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsThe Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
 
NoSQL and MongoDB
NoSQL and MongoDBNoSQL and MongoDB
NoSQL and MongoDB
 
NOSQL and MongoDB Database
NOSQL and MongoDB DatabaseNOSQL and MongoDB Database
NOSQL and MongoDB Database
 
NoSQL: An Analysis
NoSQL: An AnalysisNoSQL: An Analysis
NoSQL: An Analysis
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
A Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - HabilelabsA Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - Habilelabs
 
A rubyist's naive comparison of some database systems and toolkits
A rubyist's naive comparison of some database systems and toolkitsA rubyist's naive comparison of some database systems and toolkits
A rubyist's naive comparison of some database systems and toolkits
 
Mongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in BangaloreMongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in Bangalore
 
mongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputingmongodb-120401144140-phpapp01 claud camputing
mongodb-120401144140-phpapp01 claud camputing
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
 
Jumpstart: Building Your First MongoDB App
Jumpstart: Building Your First MongoDB AppJumpstart: Building Your First MongoDB App
Jumpstart: Building Your First MongoDB App
 

Kürzlich hochgeladen

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Kürzlich hochgeladen (20)

BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

Presentation: mongo db & elasticsearch & membase

  • 1. MongoDB ElasticSearch Couchbase Prepared by: Shalkarbayuly A. (PhD student) Presentation was prepared for “Database Management” course as a part of PhD program in Turgut Ozal University
  • 2. 1. NoSQL databases 2. MongoDB 3. ElasticSearch 4. Couchbase
  • 4. NoSQL databases NOSQL sometimes stands for Not Only SQL NOSQL is mechanism for storage and retrieval of data other than tabular data Motivations are simplicity of design, horizontal scaling, control over availability
  • 5. Problems of RD solved by NoSQL ★ RD will not scale to your traffic at an acceptable cost ★ NoSQL provides a tool to develop new features easily. ★ NoSQL have local data transactions which do not have to be very durable. e.g. “liking” items on websites.
  • 6. Avoid NoSQL ➢If application requires run-time flexibility. ➢If application requires ACID ➢if application requires complicated queries ➢if application requires query language ➢If consistency is mandatory and there will be no drastic changes in data volume, relational databases would be a better option
  • 7.
  • 8. What is MongoDB? ★ MongoDB is cross-platform ★ MongoDB is document-oriented database ★ MongoDB is a NoSQL database ★ MongoDB stores data in JSON-like documents
  • 9. MongoDB philosophy Keep functionality when we can Non-relational makes scaling horizontally practical Document models are good Database technology should run anywhere VMs, cloud, metal, etc
  • 10. Use cases for MongoDB Need of horizontal scaling: storing in many regular servers Iterative development: regular changes of database’s structure Document-oriented logic: web page is important than data
  • 12. Goal: create Web-application for e-commerce Products: there is no specific products, different type of products may be sold on webapp Problem: design database schema E-commerce: sample problem
  • 13. Product_Book{ id, name, shipping_info, price, description, ………. author, title, publisher, edition, ISBN } Product_Media{ id, name, shipping_info, price, description, ………. artist, title, track_listing, label, format } Simple solution: each time create table for specific product type Problem: very complex code, creating table, rewriting app takes time and causes errors, items cannot be considered as one item RELATIONALDATABASE approach
  • 14. Product{ id, name, shipping_info, price, description, field1_value, field1_name, field2_value, field2_name, } Product{ id, name, shipping_info, price, description, type, author, artist, track_listing, ISBN, } Set of fields with value and name Problems: what if there are many fields, how to find all books All types of attributes in one table Problems: new items causes changes in code and table RELATIONALDATABASE approach
  • 15. Book{ title, author, ISBN, } Product{ id, name, shipping_info, price, description, type (whether book or media) } Creating polymorphic tables Problems: need extra JOINS, which causes increase of speed RELATIONALDATABASE approach
  • 16. MongoDB rescues ★ Flexible schema ★ Easily searchable ★ Easily accessible ★ Fast
  • 17. {title: “Matrix”, price: 3500, details:{actors:[‘Keanu Reaves’,’’K. Zeta Jones’]}} {title: “Sherlock Holmes”, price: 2100, details:{ISBN:33002A,author:”Conan Doyle”}} ★ MongoDB stores data in document form ○ Don’t need schema ○ Store in JSON form ○ Datas are edited in application ★ No JOINS ○ Data is loaded in LINEAR time
  • 18. CRUD operations Retrieving, creating, updating, deleting operations are done on application side There is no SQL queries if software has many apps (on different platforms) it is BAD. Because you have to write logic each time if software has one app it is GOOD. Because you don’t have to mess with SQL code
  • 19. MongoDB: java example //Create String json = “{‘name’:’Mike’,’surname’:’Smith’}”; DBObject dbObject = (DBObject)JSON.parse(json); collection.insert(dbObject); //Retrieve db.products.find({‘title’:”The Matrix”}); //Update BasicDBObject newD = new BasicDBObject(); newD.append("$set",new BasicDBObject().append("clients", 110)); BasicDBObject sq = new BasicDBObject().append("name", "Mike"); collection.update(sq, newD);
  • 20. ElasticSearch ★ Real-time data ★ Real-time analytics ★ Distributed ★ High-availability ★ Multitenancy ★ Full-text search ★ Document-oriented ★ Schema-free ★ RESTful API ★ Build on top Apache Lucene
  • 21. Elasticsearch: important features Elasticsearch is based on Lucene Elasticsearch is ready for search of all types ➔Elasticsearch is search engine ➔Elasticsearch is document database
  • 22. What is Lucene? (small explanation) Lucene is information retrieval library, which takes documents and makes them easily searchable, through: ● indexing ● advanced analysis ● tokenization (indexing mice as mouse)
  • 23. Lucene creates inverted index, so that searching in documents is performed in linear time Indexing Searching terms in documents without indexing is doc.size x no.documents Don’t do this
  • 24. Elasticsearch: use case Elasticsearch is used as: ★ search engines ★ as a search mechanism for web-apps among main database ○ e.g. E-commerce storing data in MongoDB, while search data is stored in elasticsearch ★ as a document database
  • 25. Elasticsearch: REST Elasticsearch can be accessed through REST protocol #Inserting data PUT http://localhost:9200/movies/movie/1 {"title": "The Godfather","director": "Francis Ford Coppola"} #Getting data GET http://localhost:9200/movies/movie/1 #Delete data DELETE http://localhost:90/movies/movie/1 #Searching data POST http://localhost:9200/_search "query": { "query_string": { "query": "kill" } }
  • 27. Couchbase history Couchbase was created by combining two NoSQL databases Membase + CouchOne (principal players behind CouchDB) = Couchbase
  • 28. CouchBase ● Written in: Erlang & C ● Main point: Memcache compatible, but with persistence and clustering ● Protocol: memcached + extensions ● Very fast (200k+/sec) access of data by key ● Provides memcached-style in-memory caching buckets
  • 29. Couchbase Best used: Any application where low-latency data access, high concurrency support and high availability is a requirement. For example: Low-latency use-cases like ad targeting or highly-concurrent web apps like online gaming (e.g. Zynga).
  • 30. Couchbase Couchbase store data in key-value or in document form Couchbase is a key-value store: every Document has a Key and a Value Key can be a up to 250 characters Keys are unique, within a bucket there can be only one key Values can be JSON, string, numbers, binary blobs, special positive number
  • 31. Key-value NOSQL databases Performance: high Scalability: high Flexibility: high Complexity: none Advantage: High speed of response Disadvantage: All logic is located in app
  • 32. Couchbase java example CouchbaseClient c = new CouchbaseClient(baseURI, "default", ""); long userCounter = c.incr(“user_counter”,1,1); c.set(“user:”+userCounter,json.toJson(user)); c.set("key", 0, "Hello World"); System.out.println(c.get("key"));