SlideShare a Scribd company logo
Wojciech Sznapka13.05.2011MongoDB – document oriented databaseDoes NoSQL make sense?
AgendaNoSQL – definition and solutions,MongoDB – description and feautres,MongoDB usage,Who uses it?Schema-free,Some live examples,Does NoSQL make sense?
NoSQLIt’s a class of database management systems, the alternative for relational databases (RDBM). Sometimes people call they „next generation databases”,NoSQL databases haven’t got schema like relational systems, there’s no table joining and have good scalling facilities.
NoSQL solutionsDocument oriented:MongoDBApache CouchDBKey Value storage:Big Table (Google App Engine)Dynamo (Amazon Web Services)Apache Cassandra (Facebook)Project Voldemort (LinkedIn)
MongoDBDocument Oriented – stores JSON documetns ,Very efficient (written in C++),High scallable,Schema-free – high flexibility,Supports many software platform and has plenty programming language drivers (PHP, .NET, Java, Python, Ruby, etc.),Developping since August 2007, first release in 2009,Open Source (GNU AGPL).
MongoDB featuresStores dynamic JSON documents (internally represented as BSON – Binary JSON),Full support for indicies,Replication and high availability,Complex queries (which are also represented as JSONs),Map/Reduce mechanism – handy way of aggregation and processing data (combination of SQL’s Group By and stored procedures),GridFS – mongo’s file system, which allows to store files in database.
Where it applies?Web appliactions (logging, caching, processing huge amount of data),High load / high scalabillity,GIS solutions (it supports 2d geospatial indicies – longitude/latitude)Where it shouldn’t be used?High transactional operations (no support for ACID principle),Cases which needs SQL (many joins for example)
Who uses it?
MongoDB vs. SQL
Schema-free – no migrations!MongoDB (as every NoSQL solution) is schema-free, so if we need to put new field into existing document, we don’t need to do extra things, like Alter Table in SQL database. We just start using document with new field,It means, that we don’t need to care about an migrations – it’s done transparently.
ExamplesDocument,Aggregated document,Sorting, limiting,Advanced  searching (including regexp),PHP code.
CRUD on Documents> db.foo.insert({name: "Wojciech", age: 25, tags: ["male", "developer"]})> db.foo.insert({name: "Andreea", tags: ["female", "rt master"]})> db.foo.insert({name: "Okky", tags: ["male", "developer"]})> db.foo.update({name: "Wojciech"}, {$set: {surname: "Sznapka"}})> db.foo.remove({name: "Okky"});> db.foo.find(){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }{ "_id" : ObjectId("4dcd13ce7ffde8d258900f7c"), "name" : "Okky", "tags" : [ "male", "developer" ] }{ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "age" : 25, "name" : "Wojciech", "surname" : "Sznapka", "tags" : [ "male", "developer" ] }> db.foo.find({tags: "rt master"}){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }
Aggregated documents> db.logs.insert({msg: "error occured", details: {line: 2, severity: 3}})> db.logs.insert({msg: "user logged in", details: {severity: 10}})>  db.logs.find({'details.severity': 10}){ "_id" : ObjectId("4dcd15d77ffde8d258900f7e"), "msg" : "user logged in", "details" : { "severity" : 10 } }
Sorting and limiting> db.foo.find({}, {name: 1}).sort({name: -1}){ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "name" : "Wojciech" }{ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea" }> db.foo.find().limit(1){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }
Sorting and limiting> db.foo.find({}, {name: 1}).sort({name: -1}){ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "name" : "Wojciech" }{ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea" }> db.foo.find().limit(1){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }
Advanced queries>  db.foo.find({tags: "developer", age: {$exists: true}}){ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "age" : 25, "name" : "Wojciech", "surname" : "Sznapka", "tags" : [ "male", "developer" ] }>  db.foo.find({name: /a$/}, {name: 1}){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea" }{ "_id" : ObjectId("4dcd17ae7ffde8d258900f80"), "name" : "Tamara" }
PHP example<?php$mongo = new Mongo();$db = $mongo->foo;$collection = $db->foo;$wojtek = array("name" => "Wojciech", "tags" => array("male", "developer"), "age" => 25);$okky   = array("name" => "Okky",     "tags" => array("male", "developer"));$collection->insert($wojtek);$collection->insert($okky);$cursor = $collection->find();foreach ($cursor as $document) {    printf("Name: %s\n", $document["name"]);}
Does NoSQL make sense?Yes, if we will use NoSQL databases along with SQL, if they are needed. Dropping SQL databases completly isn’t the best idea for huge and complicated applications, but supplementing data model with NoSQL database (like MongoDB), can improve application performance and shorten development process,It should be rather „Not onyl SQL”.
Thank you for an attentionAny questions?

More Related Content

What's hot (20)

PDF
Mongo db basics
Harischandra M K
 
PDF
Introduction to MongoDB
Mike Dirolf
 
PDF
An introduction to MongoDB
Universidade de São Paulo
 
PPTX
MongoDB for Beginners
Enoch Joshua
 
PPTX
Mongo DB Presentation
Jaya Naresh Kovela
 
ODP
MongoDB : The Definitive Guide
Wildan Maulana
 
PPTX
Intro To Mongo Db
chriskite
 
PPTX
Mongo db
Raghu nath
 
ODP
MongoDB - Ekino PHP
Florent DENIS
 
PPTX
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
PPTX
Introduction to MongoDB
NodeXperts
 
PPTX
Mondodb
Paulo Fagundes
 
PPT
Introduction to MongoDB
Nosh Petigara
 
PPTX
Webinar: Back to Basics: Thinking in Documents
MongoDB
 
PPTX
Mongo db workshop # 02
FarhatParveen10
 
PDF
Intro To MongoDB
Alex Sharp
 
PPTX
MongoDB basics & Introduction
Jerwin Roy
 
PDF
Mongo db basics
Claudio Montoya
 
PPTX
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
Mongo db basics
Harischandra M K
 
Introduction to MongoDB
Mike Dirolf
 
An introduction to MongoDB
Universidade de São Paulo
 
MongoDB for Beginners
Enoch Joshua
 
Mongo DB Presentation
Jaya Naresh Kovela
 
MongoDB : The Definitive Guide
Wildan Maulana
 
Intro To Mongo Db
chriskite
 
Mongo db
Raghu nath
 
MongoDB - Ekino PHP
Florent DENIS
 
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
Introduction to MongoDB
NodeXperts
 
Introduction to MongoDB
Nosh Petigara
 
Webinar: Back to Basics: Thinking in Documents
MongoDB
 
Mongo db workshop # 02
FarhatParveen10
 
Intro To MongoDB
Alex Sharp
 
MongoDB basics & Introduction
Jerwin Roy
 
Mongo db basics
Claudio Montoya
 
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 

Similar to Mongo db – document oriented database (20)

PPTX
MongoDB Knowledge share
Mr Kyaing
 
PPTX
MongoDb In Action
fuchaoqun
 
PPTX
A Presentation on MongoDB Introduction - Habilelabs
HabileLabs
 
PDF
Mongo db eveningschemadesign
MongoDB APAC
 
PPTX
MongoDB is a document database. It stores data in a type of JSON format calle...
amintafernandos
 
PPTX
MongoDB_ppt.pptx
1AP18CS037ShirishKul
 
KEY
Schema Design with MongoDB
rogerbodamer
 
PPTX
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
PPTX
Mongodbinaction 100122230824-phpapp01
Cevin Cheung
 
PDF
Mongo DB schema design patterns
joergreichert
 
PPT
Schema design short
MongoDB
 
PDF
MongoDB.pdf
KuldeepKumar778733
 
KEY
English Casual 2012/05/10
Ryosuke IWANAGA
 
ODP
MongoDB
Martin Lazarov
 
PPT
9. Document Oriented Databases
Fabio Fumarola
 
PPTX
An Introduction To NoSQL & MongoDB
Lee Theobald
 
PPT
Mongo db tutorials
Anuj Jain
 
KEY
Schema Design (Mongo Austin)
MongoDB
 
PPTX
lecture_34e.pptx
janibashashaik25
 
PDF
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
Prasoon Kumar
 
MongoDB Knowledge share
Mr Kyaing
 
MongoDb In Action
fuchaoqun
 
A Presentation on MongoDB Introduction - Habilelabs
HabileLabs
 
Mongo db eveningschemadesign
MongoDB APAC
 
MongoDB is a document database. It stores data in a type of JSON format calle...
amintafernandos
 
MongoDB_ppt.pptx
1AP18CS037ShirishKul
 
Schema Design with MongoDB
rogerbodamer
 
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
Mongodbinaction 100122230824-phpapp01
Cevin Cheung
 
Mongo DB schema design patterns
joergreichert
 
Schema design short
MongoDB
 
MongoDB.pdf
KuldeepKumar778733
 
English Casual 2012/05/10
Ryosuke IWANAGA
 
9. Document Oriented Databases
Fabio Fumarola
 
An Introduction To NoSQL & MongoDB
Lee Theobald
 
Mongo db tutorials
Anuj Jain
 
Schema Design (Mongo Austin)
MongoDB
 
lecture_34e.pptx
janibashashaik25
 
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
Prasoon Kumar
 
Ad

More from Wojciech Sznapka (6)

PDF
Automated tests - facts and myths
Wojciech Sznapka
 
PDF
Smart development environments
Wojciech Sznapka
 
PDF
Symfony2 w chmurze
Wojciech Sznapka
 
ODP
Łebski Development czyli kiedy i dlaczego tworzyć oprogramowanie pod klucz i ...
Wojciech Sznapka
 
ODP
Symfony2 showcase
Wojciech Sznapka
 
ODP
MongoDB - baza danych zorientowana dokumentowo. Czy ruch NoSQL ma sens?
Wojciech Sznapka
 
Automated tests - facts and myths
Wojciech Sznapka
 
Smart development environments
Wojciech Sznapka
 
Symfony2 w chmurze
Wojciech Sznapka
 
Łebski Development czyli kiedy i dlaczego tworzyć oprogramowanie pod klucz i ...
Wojciech Sznapka
 
Symfony2 showcase
Wojciech Sznapka
 
MongoDB - baza danych zorientowana dokumentowo. Czy ruch NoSQL ma sens?
Wojciech Sznapka
 
Ad

Recently uploaded (20)

PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PDF
Home Cleaning App Development Services.pdf
V3cube
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
PPTX
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
Home Cleaning App Development Services.pdf
V3cube
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 

Mongo db – document oriented database

  • 1. Wojciech Sznapka13.05.2011MongoDB – document oriented databaseDoes NoSQL make sense?
  • 2. AgendaNoSQL – definition and solutions,MongoDB – description and feautres,MongoDB usage,Who uses it?Schema-free,Some live examples,Does NoSQL make sense?
  • 3. NoSQLIt’s a class of database management systems, the alternative for relational databases (RDBM). Sometimes people call they „next generation databases”,NoSQL databases haven’t got schema like relational systems, there’s no table joining and have good scalling facilities.
  • 4. NoSQL solutionsDocument oriented:MongoDBApache CouchDBKey Value storage:Big Table (Google App Engine)Dynamo (Amazon Web Services)Apache Cassandra (Facebook)Project Voldemort (LinkedIn)
  • 5. MongoDBDocument Oriented – stores JSON documetns ,Very efficient (written in C++),High scallable,Schema-free – high flexibility,Supports many software platform and has plenty programming language drivers (PHP, .NET, Java, Python, Ruby, etc.),Developping since August 2007, first release in 2009,Open Source (GNU AGPL).
  • 6. MongoDB featuresStores dynamic JSON documents (internally represented as BSON – Binary JSON),Full support for indicies,Replication and high availability,Complex queries (which are also represented as JSONs),Map/Reduce mechanism – handy way of aggregation and processing data (combination of SQL’s Group By and stored procedures),GridFS – mongo’s file system, which allows to store files in database.
  • 7. Where it applies?Web appliactions (logging, caching, processing huge amount of data),High load / high scalabillity,GIS solutions (it supports 2d geospatial indicies – longitude/latitude)Where it shouldn’t be used?High transactional operations (no support for ACID principle),Cases which needs SQL (many joins for example)
  • 10. Schema-free – no migrations!MongoDB (as every NoSQL solution) is schema-free, so if we need to put new field into existing document, we don’t need to do extra things, like Alter Table in SQL database. We just start using document with new field,It means, that we don’t need to care about an migrations – it’s done transparently.
  • 12. CRUD on Documents> db.foo.insert({name: "Wojciech", age: 25, tags: ["male", "developer"]})> db.foo.insert({name: "Andreea", tags: ["female", "rt master"]})> db.foo.insert({name: "Okky", tags: ["male", "developer"]})> db.foo.update({name: "Wojciech"}, {$set: {surname: "Sznapka"}})> db.foo.remove({name: "Okky"});> db.foo.find(){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }{ "_id" : ObjectId("4dcd13ce7ffde8d258900f7c"), "name" : "Okky", "tags" : [ "male", "developer" ] }{ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "age" : 25, "name" : "Wojciech", "surname" : "Sznapka", "tags" : [ "male", "developer" ] }> db.foo.find({tags: "rt master"}){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }
  • 13. Aggregated documents> db.logs.insert({msg: "error occured", details: {line: 2, severity: 3}})> db.logs.insert({msg: "user logged in", details: {severity: 10}})> db.logs.find({'details.severity': 10}){ "_id" : ObjectId("4dcd15d77ffde8d258900f7e"), "msg" : "user logged in", "details" : { "severity" : 10 } }
  • 14. Sorting and limiting> db.foo.find({}, {name: 1}).sort({name: -1}){ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "name" : "Wojciech" }{ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea" }> db.foo.find().limit(1){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }
  • 15. Sorting and limiting> db.foo.find({}, {name: 1}).sort({name: -1}){ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "name" : "Wojciech" }{ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea" }> db.foo.find().limit(1){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea", "tags" : [ "female", "rt master" ] }
  • 16. Advanced queries> db.foo.find({tags: "developer", age: {$exists: true}}){ "_id" : ObjectId("4dcd13647ffde8d258900f7a"), "age" : 25, "name" : "Wojciech", "surname" : "Sznapka", "tags" : [ "male", "developer" ] }> db.foo.find({name: /a$/}, {name: 1}){ "_id" : ObjectId("4dcd13b37ffde8d258900f7b"), "name" : "Andreea" }{ "_id" : ObjectId("4dcd17ae7ffde8d258900f80"), "name" : "Tamara" }
  • 17. PHP example<?php$mongo = new Mongo();$db = $mongo->foo;$collection = $db->foo;$wojtek = array("name" => "Wojciech", "tags" => array("male", "developer"), "age" => 25);$okky = array("name" => "Okky", "tags" => array("male", "developer"));$collection->insert($wojtek);$collection->insert($okky);$cursor = $collection->find();foreach ($cursor as $document) { printf("Name: %s\n", $document["name"]);}
  • 18. Does NoSQL make sense?Yes, if we will use NoSQL databases along with SQL, if they are needed. Dropping SQL databases completly isn’t the best idea for huge and complicated applications, but supplementing data model with NoSQL database (like MongoDB), can improve application performance and shorten development process,It should be rather „Not onyl SQL”.
  • 19. Thank you for an attentionAny questions?