SlideShare a Scribd company logo
Introduction
  to NoSQL
And MongoDB

Behrouz Bakhtiari
  Farid Dehgan
ntroduction to NOSQL And MongoDB

nes are correct?

    NOSQL = Not To
    SQL
    NOSQL = Not Only SQL
ntroduction to NOSQL And MongoDB

High Throughput

Reduce Cost
Eliminate ORM Complexity
ntroduction to NOSQL And MongoDB

Horizontal Scalability
ntroduction to NOSQL And MongoDB

Horizontal Scalability




“Oracle would tell you that with the right degree of hardware and the right configuration of Oracle RAC (Real Application Clusters) and other
associated magic software, you can achieve the same scalability. But at what cost?”
ntroduction to NOSQL And MongoDB

The CAP-Theorem
ntroduction to NOSQL And MongoDB

Consistenc
y
ntroduction to NOSQL And MongoDB

Availability
ntroduction to NOSQL And MongoDB

Partition Tolerance
ntroduction to NOSQL And MongoDB




                                     Not
                               Available
ntroduction to NOSQL And MongoDB

 ACID
    Atomic
    Consistent
    Isolated
    Durable
ntroduction to NOSQL And MongoDB

BASE
  Base Availability

  Soft-state
                             Not
                          durabl
ual consistency                e
ntroduction to NOSQL And MongoDB

NOSQL Taxonomy
    Key-Value Stores

    Column Stores

    Document Stores

    Graph Databases
ntroduction to NOSQL And MongoDB

Key-Value Stores

     Automobile
     Key   Attributes
     1     Make: Toyota
           Model: Highlander
           Color: Maroon
           Year: 2004

     2     Make: Toyota
           Model: Highlander
           Color: Blue
           Year: 2005
           Transmission: Automatic
ntroduction to NOSQL And MongoDB

Dynamo DB
  Amazon


  Key-Value

  Consistent


  Hashing
ntroduction to NOSQL And MongoDB

Column
Stores            EmpId    Lastname     Firstname   Salary
                  1        Smith        Joe         40000
                  2        Jones        Mary        50000
                  3        Johnson      Cathy       44000


     A Row-oriented Database: puts rows together
     1,Smith,Joe,40000; 2,Jones,Mary,50000; 3,Johnson,Cathy,44000;


     A Column-oriented Database: puts values of a column together.
     1,2,3; Smith,Jones,Johnson; Joe,Mary,Cathy; 40000,50000,44000;
ntroduction to NOSQL And MongoDB

BigTable
  Sparse (rows only where there are

  values; not fixed length)

  Distributed (horizontally partitioned

  over many servers)

  Multidimensional (consisting of a

  multi-part key)
ntroduction to NOSQL And MongoDB

MapReduce
ntroduction to NOSQL And MongoDB

Graph Databases
ntroduction to NOSQL And MongoDB

Graph Vs. Key-
Value
ntroduction to NOSQL And MongoDB

JSON
ntroduction to NOSQL And MongoDB

Documents
                         Documents = Rows
  In MongoDB the documents are conceptually JSON.



  documents can be thought of as objects but only the data of an object, not the code, methods or class hierarchy



  MongoDB is type-sensitive and case-sensitive. {“foo” : 3} # {“foo” : “3”} Or {“foo” : 3} # {“Foo” : 3}
ntroduction to NOSQL And MongoDB

Collections
                            Collections = Tables
   A MongoDB collection is a collection of BSON documents.


   Collections are schema-free.


   A collection is created when the first document is inserted.


   The maximum size of a collection name is 128 characters (including the name of the db and indexes).
ntroduction to NOSQL And MongoDB

Getting and Starting MongoD
                                                                                                        Default port for server
To start the server, run the mongod executable.




                                                   Default data directory : C:datadb

                                          If directory.exist(“C:datadb”) == false then server.fail

                                                         > mongod --dbpath D:data
ntroduction to NOSQL And MongoDB

MongoDB Shell
I want to interact with MongoDB
                                    > mongo


                                         make sure you start mongod before starting the shell.




                                  > X = 200                  > Math.sin(Math.PI / 2 );
                                  200                        1
                                  >X/5                       > “TOSS”.replace(“T”,”Tabriz ”);
                                  40                         Tabriz OSS
ntroduction to NOSQL And MongoDB

Creating Documents
> db.post.insert({ID: 1,Title:“TDD",Body:"Unit Test"})

> db.post.insert({ID: 2,Title:"NOSQL",Body:"Introduction to NOSQL",Authors:["Farid"]})

> db.post.insert({ID: 3,Title:"MongoDB",Body:"Introduction to MongoDB",Authors:["Farid",“Behrouz"]})
                                                 Mapping To Relational Modal



                            Post                         PostAuthors              Authors




> INSERT INTO Authors ( ID , Name) Values ( 1 , ' Behrouz' )

> INSERT INTO Authors ( ID , Name) Values ( 2 , ' Farid' )

> INSERT INTO post ( ID , Title , Body ) Values ( 3 , ' MongoDB „ , ' Introduction to MongoDB ' )

> INSERT INTO PostAuthors (Post ID , AuthorID) Values ( 3 , 1)

> INSERT INTO PostAuthors (Post ID , AuthorID) Values ( 3 , 2)
ntroduction to NOSQL And MongoDB

Deleting Documents
 > DELETE FROM post




 > db.post.remove()


 > DELETE FROM post WHERE ID = 1




 > db.post.remove({ ID : 1 })


 > DELETE FROM post WHERE ID = 1 AND Title = „TDD‟




 > db.post.remove({ ID : 1 , Title : " TDD " })
ntroduction to NOSQL And MongoDB

Updating Documents
> UPDATE post SET Title = „Mocking‟ Where ID = 1                          Updates, update by default only the first
                                                                          documents that matches the criteria.




> db.post.update( { ID: 1 } , { "$set" : {Title : "Mocking“ } } )




> db.post.update( { ID: 1 } , { "$set" : {Title : "Mocking“ } } ,false , true)



                                                                    Upsert ?
ntroduction to NOSQL And MongoDB

Updating Documents
> db.post.update( { ID: 1o1 } , { "$set" : { Title : “Scrum“ , Body : “Scrum” } } , true)




                                                              Yes
                                      Exist this document               Update document
                                                 No




                                     Create a new document

                                         {ID : 101}
ntroduction to NOSQL And MongoDB

Updating Documents
> db.post.update( {ID : 3 } , { "$set" : { comments : [{ Email : "behrouzlo@yahoo.com" , Body : "Test“ }]}})




                                                    Mapping To Relational Modal


                                     Post                                             Comments
                                              1                                   *




        > INSERT INTO comments ( postID , Email , Body ) VALUES ( 3 , ‟behrouzlo@yahoo.com‟ , ‟Test‟ )
ntroduction to NOSQL And MongoDB

Querying
> SELECT * FROM post



> db.post.find()




> SELECT ID , Title FROM post
                                                        The _id key is always returned, even if it isn‟t specifically listed.




> db.post.find({} , { ID : 1 , Title : 1 })




> db.post.find({} , { ID : 1 , Title : 1 , _id : 0 })
ntroduction to NOSQL And MongoDB

Querying
> SELECT * FROM post WHERE ID = 1



> db.post.find({ ID : 1 })




> SELECT * FROM post WHERE ID = 1 OR ID = 3



> db.post.find( { “$or” : [{ ID = 1 } , { ID = 3 } ] } )
ntroduction to NOSQL And MongoDB

Querying
$lt       <             $lte         <=            $gt      >   $gte   >=   $ne   <>



> SELECT * FROM post WHERE ID >= 1 And ID <= 100

> db.post.find ( { ID : { “$gte” : 1 , “$lte” : 100 } } )




> SELECT * FROM post WHERE ID <> 1


> db.post.find ( { ID : { “$ne” : 1} } )
ntroduction to NOSQL And MongoDB

Querying
> SELECT * FROM post WHERE ID = 1



> db.post.find({ ID : 1 })




> SELECT * FROM post WHERE ID = 1 OR ID = 3



> db.post.find( { “$or” : [{ ID = 1 } , { ID = 3 } ] } )
ntroduction to NOSQL And MongoDB

Querying
> SELECT * FROM post ORDER BY ID




> db.post.find().sort ( { ID : 1 } )




> SELECT * FROM post ORDER BY ID DESC




> db.post.find().sort ( { ID : -1 } )
ntroduction to NOSQL And MongoDB

More Related Content

What's hot

Mongo db basic installation
Mongo db basic installationMongo db basic installation
Mongo db basic installation
Kishor Parkhe
 
Sqlxml vs xquery
Sqlxml vs xquerySqlxml vs xquery
Sqlxml vs xqueryAmol Pujari
 
Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)MongoSF
 
Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012yantoit2011
 
Mongo db queries
Mongo db queriesMongo db queries
Mongo db queries
ssuser6d5faa
 
Mongo indexes
Mongo indexesMongo indexes
Mongo indexes
paradokslabs
 
Postgresql search demystified
Postgresql search demystifiedPostgresql search demystified
Postgresql search demystified
javier ramirez
 
Morphia: Simplifying Persistence for Java and MongoDB
Morphia:  Simplifying Persistence for Java and MongoDBMorphia:  Simplifying Persistence for Java and MongoDB
Morphia: Simplifying Persistence for Java and MongoDBJeff Yemin
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
antoinegirbal
 
Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development with MongoDB
James Williams
 
Mongo Nosql CRUD Operations
Mongo Nosql CRUD OperationsMongo Nosql CRUD Operations
Mongo Nosql CRUD Operations
anujaggarwal49
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)
MongoDB
 
Simplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with MorphiaSimplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with Morphia
MongoDB
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction
antoinegirbal
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programming
Anand Dhana
 
Storing tree structures with MongoDB
Storing tree structures with MongoDBStoring tree structures with MongoDB
Storing tree structures with MongoDB
Vyacheslav
 
Indexing & Query Optimization
Indexing & Query OptimizationIndexing & Query Optimization
Indexing & Query OptimizationMongoDB
 
Indexing and Query Optimization
Indexing and Query OptimizationIndexing and Query Optimization
Indexing and Query OptimizationMongoDB
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
Scott Hernandez
 

What's hot (20)

Mongo db basic installation
Mongo db basic installationMongo db basic installation
Mongo db basic installation
 
Sqlxml vs xquery
Sqlxml vs xquerySqlxml vs xquery
Sqlxml vs xquery
 
Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)Indexing and Query Optimizer (Aaron Staple)
Indexing and Query Optimizer (Aaron Staple)
 
Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012
 
Mongo db queries
Mongo db queriesMongo db queries
Mongo db queries
 
DB2 Native XML
DB2 Native XMLDB2 Native XML
DB2 Native XML
 
Mongo indexes
Mongo indexesMongo indexes
Mongo indexes
 
Postgresql search demystified
Postgresql search demystifiedPostgresql search demystified
Postgresql search demystified
 
Morphia: Simplifying Persistence for Java and MongoDB
Morphia:  Simplifying Persistence for Java and MongoDBMorphia:  Simplifying Persistence for Java and MongoDB
Morphia: Simplifying Persistence for Java and MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development with MongoDB
 
Mongo Nosql CRUD Operations
Mongo Nosql CRUD OperationsMongo Nosql CRUD Operations
Mongo Nosql CRUD Operations
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)
 
Simplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with MorphiaSimplifying Persistence for Java and MongoDB with Morphia
Simplifying Persistence for Java and MongoDB with Morphia
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programming
 
Storing tree structures with MongoDB
Storing tree structures with MongoDBStoring tree structures with MongoDB
Storing tree structures with MongoDB
 
Indexing & Query Optimization
Indexing & Query OptimizationIndexing & Query Optimization
Indexing & Query Optimization
 
Indexing and Query Optimization
Indexing and Query OptimizationIndexing and Query Optimization
Indexing and Query Optimization
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 

Viewers also liked

Flateel
FlateelFlateel
Introdução às Metodologias Ágeis de Desenvolvimento
Introdução às Metodologias Ágeis de DesenvolvimentoIntrodução às Metodologias Ágeis de Desenvolvimento
Introdução às Metodologias Ágeis de Desenvolvimento
Jerry Medeiros
 
2008 cafe tirana
2008 cafe tirana2008 cafe tirana
ipsum.pdf
ipsum.pdfipsum.pdf
ipsum.pdf
reezo21
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
Abu Saleh
 
24 as-3-mensagens-angelicaspps3335
24 as-3-mensagens-angelicaspps333524 as-3-mensagens-angelicaspps3335
24 as-3-mensagens-angelicaspps3335O ÚLTIMO CHAMADO
 
DevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at AcquiaDevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at Acquia
Marc Seeger
 
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB FinancialVancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
Glassdoor
 
Etl tool
Etl toolEtl tool
Etl tool
Jinal Shah
 
AMI - Bringing Your Own Device to ITAM
AMI - Bringing Your Own Device to ITAMAMI - Bringing Your Own Device to ITAM
AMI - Bringing Your Own Device to ITAM
AMI - Asset Management International
 
компьютерное тестирование аттестующихся работников образования рт
компьютерное тестирование аттестующихся работников образования рткомпьютерное тестирование аттестующихся работников образования рт
компьютерное тестирование аттестующихся работников образования ртAirat Yusupov
 
Opendataday
OpendatadayOpendataday
Opendataday
Sandra Troia
 
Arquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e CenáriosArquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e Cenáriosposgraduacaorj
 
нові надходження червня2015
нові надходження червня2015нові надходження червня2015
нові надходження червня2015Maryna Zaharova
 

Viewers also liked (20)

Flateel
FlateelFlateel
Flateel
 
Mfhp12 c excel_4ed_solucoes
Mfhp12 c excel_4ed_solucoesMfhp12 c excel_4ed_solucoes
Mfhp12 c excel_4ed_solucoes
 
PLUG VLAVE - PIN-Layout1
PLUG VLAVE - PIN-Layout1PLUG VLAVE - PIN-Layout1
PLUG VLAVE - PIN-Layout1
 
Introdução às Metodologias Ágeis de Desenvolvimento
Introdução às Metodologias Ágeis de DesenvolvimentoIntrodução às Metodologias Ágeis de Desenvolvimento
Introdução às Metodologias Ágeis de Desenvolvimento
 
Decimales: Valor Posicional
Decimales: Valor PosicionalDecimales: Valor Posicional
Decimales: Valor Posicional
 
2008 cafe tirana
2008 cafe tirana2008 cafe tirana
2008 cafe tirana
 
Tefa
TefaTefa
Tefa
 
ipsum.pdf
ipsum.pdfipsum.pdf
ipsum.pdf
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
 
24 as-3-mensagens-angelicaspps3335
24 as-3-mensagens-angelicaspps333524 as-3-mensagens-angelicaspps3335
24 as-3-mensagens-angelicaspps3335
 
DevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at AcquiaDevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at Acquia
 
Brin 3 q12
Brin   3 q12Brin   3 q12
Brin 3 q12
 
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB FinancialVancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
 
Etl tool
Etl toolEtl tool
Etl tool
 
AMI - Bringing Your Own Device to ITAM
AMI - Bringing Your Own Device to ITAMAMI - Bringing Your Own Device to ITAM
AMI - Bringing Your Own Device to ITAM
 
Curso deferias
Curso deferiasCurso deferias
Curso deferias
 
компьютерное тестирование аттестующихся работников образования рт
компьютерное тестирование аттестующихся работников образования рткомпьютерное тестирование аттестующихся работников образования рт
компьютерное тестирование аттестующихся работников образования рт
 
Opendataday
OpendatadayOpendataday
Opendataday
 
Arquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e CenáriosArquitetura de Informação - Personas e Cenários
Arquitetura de Informação - Personas e Cenários
 
нові надходження червня2015
нові надходження червня2015нові надходження червня2015
нові надходження червня2015
 

Similar to Introduction to NOSQL And MongoDB

MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
Steven Francia
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBAlex Bilbie
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
Nate Abele
 
Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.
Andrii Lashchenko
 
Mongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg SolutionsMongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg Solutions
Metatagg Solutions
 
Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Kai Zhao
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012Yaqi Zhao
 
Intro to mongodb mongouk jun2010
Intro to mongodb mongouk jun2010Intro to mongodb mongouk jun2010
Intro to mongodb mongouk jun2010Skills Matter
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
MongoDB
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo dbDaeMyung Kang
 
MongoDB
MongoDBMongoDB
MongoDB
kesavan N B
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Groupkchodorow
 
MongoDB (Advanced)
MongoDB (Advanced)MongoDB (Advanced)
MongoDB (Advanced)
TO THE NEW | Technology
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
Building your first app with mongo db
Building your first app with mongo dbBuilding your first app with mongo db
Building your first app with mongo db
MongoDB
 
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
boychatmate1
 
What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?
Trisha Gee
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
S.Shayan Daneshvar
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
Dhaval Mistry
 

Similar to Introduction to NOSQL And MongoDB (20)

MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
Latinoware
LatinowareLatinoware
Latinoware
 
Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.
 
Mongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg SolutionsMongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg Solutions
 
Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012
 
Intro to mongodb mongouk jun2010
Intro to mongodb mongouk jun2010Intro to mongodb mongouk jun2010
Intro to mongodb mongouk jun2010
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo db
 
MongoDB
MongoDBMongoDB
MongoDB
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
MongoDB (Advanced)
MongoDB (Advanced)MongoDB (Advanced)
MongoDB (Advanced)
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Building your first app with mongo db
Building your first app with mongo dbBuilding your first app with mongo db
Building your first app with mongo db
 
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
 
What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 

Recently uploaded

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 

Recently uploaded (20)

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 

Introduction to NOSQL And MongoDB

  • 1. Introduction to NoSQL And MongoDB Behrouz Bakhtiari Farid Dehgan
  • 2. ntroduction to NOSQL And MongoDB nes are correct? NOSQL = Not To SQL NOSQL = Not Only SQL
  • 3. ntroduction to NOSQL And MongoDB High Throughput Reduce Cost Eliminate ORM Complexity
  • 4. ntroduction to NOSQL And MongoDB Horizontal Scalability
  • 5. ntroduction to NOSQL And MongoDB Horizontal Scalability “Oracle would tell you that with the right degree of hardware and the right configuration of Oracle RAC (Real Application Clusters) and other associated magic software, you can achieve the same scalability. But at what cost?”
  • 6. ntroduction to NOSQL And MongoDB The CAP-Theorem
  • 7. ntroduction to NOSQL And MongoDB Consistenc y
  • 8. ntroduction to NOSQL And MongoDB Availability
  • 9. ntroduction to NOSQL And MongoDB Partition Tolerance
  • 10. ntroduction to NOSQL And MongoDB Not Available
  • 11. ntroduction to NOSQL And MongoDB ACID Atomic Consistent Isolated Durable
  • 12. ntroduction to NOSQL And MongoDB BASE Base Availability Soft-state Not durabl ual consistency e
  • 13. ntroduction to NOSQL And MongoDB NOSQL Taxonomy Key-Value Stores Column Stores Document Stores Graph Databases
  • 14. ntroduction to NOSQL And MongoDB Key-Value Stores Automobile Key Attributes 1 Make: Toyota Model: Highlander Color: Maroon Year: 2004 2 Make: Toyota Model: Highlander Color: Blue Year: 2005 Transmission: Automatic
  • 15. ntroduction to NOSQL And MongoDB Dynamo DB Amazon Key-Value Consistent Hashing
  • 16. ntroduction to NOSQL And MongoDB Column Stores EmpId Lastname Firstname Salary 1 Smith Joe 40000 2 Jones Mary 50000 3 Johnson Cathy 44000 A Row-oriented Database: puts rows together 1,Smith,Joe,40000; 2,Jones,Mary,50000; 3,Johnson,Cathy,44000; A Column-oriented Database: puts values of a column together. 1,2,3; Smith,Jones,Johnson; Joe,Mary,Cathy; 40000,50000,44000;
  • 17. ntroduction to NOSQL And MongoDB BigTable Sparse (rows only where there are values; not fixed length) Distributed (horizontally partitioned over many servers) Multidimensional (consisting of a multi-part key)
  • 18. ntroduction to NOSQL And MongoDB MapReduce
  • 19. ntroduction to NOSQL And MongoDB Graph Databases
  • 20. ntroduction to NOSQL And MongoDB Graph Vs. Key- Value
  • 21. ntroduction to NOSQL And MongoDB JSON
  • 22. ntroduction to NOSQL And MongoDB Documents Documents = Rows In MongoDB the documents are conceptually JSON. documents can be thought of as objects but only the data of an object, not the code, methods or class hierarchy MongoDB is type-sensitive and case-sensitive. {“foo” : 3} # {“foo” : “3”} Or {“foo” : 3} # {“Foo” : 3}
  • 23. ntroduction to NOSQL And MongoDB Collections Collections = Tables A MongoDB collection is a collection of BSON documents. Collections are schema-free. A collection is created when the first document is inserted. The maximum size of a collection name is 128 characters (including the name of the db and indexes).
  • 24. ntroduction to NOSQL And MongoDB Getting and Starting MongoD Default port for server To start the server, run the mongod executable. Default data directory : C:datadb If directory.exist(“C:datadb”) == false then server.fail > mongod --dbpath D:data
  • 25. ntroduction to NOSQL And MongoDB MongoDB Shell I want to interact with MongoDB > mongo make sure you start mongod before starting the shell. > X = 200 > Math.sin(Math.PI / 2 ); 200 1 >X/5 > “TOSS”.replace(“T”,”Tabriz ”); 40 Tabriz OSS
  • 26. ntroduction to NOSQL And MongoDB Creating Documents > db.post.insert({ID: 1,Title:“TDD",Body:"Unit Test"}) > db.post.insert({ID: 2,Title:"NOSQL",Body:"Introduction to NOSQL",Authors:["Farid"]}) > db.post.insert({ID: 3,Title:"MongoDB",Body:"Introduction to MongoDB",Authors:["Farid",“Behrouz"]}) Mapping To Relational Modal Post PostAuthors Authors > INSERT INTO Authors ( ID , Name) Values ( 1 , ' Behrouz' ) > INSERT INTO Authors ( ID , Name) Values ( 2 , ' Farid' ) > INSERT INTO post ( ID , Title , Body ) Values ( 3 , ' MongoDB „ , ' Introduction to MongoDB ' ) > INSERT INTO PostAuthors (Post ID , AuthorID) Values ( 3 , 1) > INSERT INTO PostAuthors (Post ID , AuthorID) Values ( 3 , 2)
  • 27. ntroduction to NOSQL And MongoDB Deleting Documents > DELETE FROM post > db.post.remove() > DELETE FROM post WHERE ID = 1 > db.post.remove({ ID : 1 }) > DELETE FROM post WHERE ID = 1 AND Title = „TDD‟ > db.post.remove({ ID : 1 , Title : " TDD " })
  • 28. ntroduction to NOSQL And MongoDB Updating Documents > UPDATE post SET Title = „Mocking‟ Where ID = 1 Updates, update by default only the first documents that matches the criteria. > db.post.update( { ID: 1 } , { "$set" : {Title : "Mocking“ } } ) > db.post.update( { ID: 1 } , { "$set" : {Title : "Mocking“ } } ,false , true) Upsert ?
  • 29. ntroduction to NOSQL And MongoDB Updating Documents > db.post.update( { ID: 1o1 } , { "$set" : { Title : “Scrum“ , Body : “Scrum” } } , true) Yes Exist this document Update document No Create a new document {ID : 101}
  • 30. ntroduction to NOSQL And MongoDB Updating Documents > db.post.update( {ID : 3 } , { "$set" : { comments : [{ Email : "behrouzlo@yahoo.com" , Body : "Test“ }]}}) Mapping To Relational Modal Post Comments 1 * > INSERT INTO comments ( postID , Email , Body ) VALUES ( 3 , ‟behrouzlo@yahoo.com‟ , ‟Test‟ )
  • 31. ntroduction to NOSQL And MongoDB Querying > SELECT * FROM post > db.post.find() > SELECT ID , Title FROM post The _id key is always returned, even if it isn‟t specifically listed. > db.post.find({} , { ID : 1 , Title : 1 }) > db.post.find({} , { ID : 1 , Title : 1 , _id : 0 })
  • 32. ntroduction to NOSQL And MongoDB Querying > SELECT * FROM post WHERE ID = 1 > db.post.find({ ID : 1 }) > SELECT * FROM post WHERE ID = 1 OR ID = 3 > db.post.find( { “$or” : [{ ID = 1 } , { ID = 3 } ] } )
  • 33. ntroduction to NOSQL And MongoDB Querying $lt < $lte <= $gt > $gte >= $ne <> > SELECT * FROM post WHERE ID >= 1 And ID <= 100 > db.post.find ( { ID : { “$gte” : 1 , “$lte” : 100 } } ) > SELECT * FROM post WHERE ID <> 1 > db.post.find ( { ID : { “$ne” : 1} } )
  • 34. ntroduction to NOSQL And MongoDB Querying > SELECT * FROM post WHERE ID = 1 > db.post.find({ ID : 1 }) > SELECT * FROM post WHERE ID = 1 OR ID = 3 > db.post.find( { “$or” : [{ ID = 1 } , { ID = 3 } ] } )
  • 35. ntroduction to NOSQL And MongoDB Querying > SELECT * FROM post ORDER BY ID > db.post.find().sort ( { ID : 1 } ) > SELECT * FROM post ORDER BY ID DESC > db.post.find().sort ( { ID : -1 } )
  • 36. ntroduction to NOSQL And MongoDB