SlideShare une entreprise Scribd logo
1  sur  36
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

Contenu connexe

Tendances

Mongo db basic installation
Mongo db basic installationMongo db basic installation
Mongo db basic installationKishor 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
 
Postgresql search demystified
Postgresql search demystifiedPostgresql search demystified
Postgresql search demystifiedjavier 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 MongoDBantoinegirbal
 
Java development with MongoDB
Java development with MongoDBJava development with MongoDB
Java development with MongoDBJames Williams
 
Mongo Nosql CRUD Operations
Mongo Nosql CRUD OperationsMongo Nosql CRUD Operations
Mongo Nosql CRUD Operationsanujaggarwal49
 
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 MorphiaMongoDB
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introductionantoinegirbal
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programmingAnand Dhana
 
Storing tree structures with MongoDB
Storing tree structures with MongoDBStoring tree structures with MongoDB
Storing tree structures with MongoDBVyacheslav
 
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 MorphiaScott Hernandez
 

Tendances (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
 

En vedette

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 DesenvolvimentoJerry Medeiros
 
ipsum.pdf
ipsum.pdfipsum.pdf
ipsum.pdfreezo21
 
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 AcquiaMarc 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 FinancialGlassdoor
 
компьютерное тестирование аттестующихся работников образования рт
компьютерное тестирование аттестующихся работников образования рткомпьютерное тестирование аттестующихся работников образования рт
компьютерное тестирование аттестующихся работников образования ртAirat Yusupov
 
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
 

En vedette (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
 

Similaire à 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 2011Steven 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 MongoDBNate 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 SolutionsMetatagg 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 MongoDBMongoDB
 
Superficial mongo db
Superficial mongo dbSuperficial mongo db
Superficial mongo dbDaeMyung Kang
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Groupkchodorow
 
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 MongoDBMongoDB
 
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 dbMongoDB
 
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
 

Similaire à 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
 

Dernier

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 

Dernier (20)

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 

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