Presented by: Group Members
Zubair Ahmed, Jameel Ahmed, Naeem Jan and Hassam Hamid
Instructor: Mr. Mukhtar Hussain
Class: BSCS 8th (2015-2018)
Presented by: Group Members
Date:Tuesday, September 11, 2018
Department: Computer Science
University ofTurbat2 |
PresentationTasks
1) Introduction to MongoDB By Jameel
Ahmed
2) Installing MongoDB By Naeem Jan
3) MongoDB Data Modelling By Zubair
Ahmed
4) MongoDB CRUD Operations By Hassam
Hamid
University ofTurbat3 |
Introduction
University ofTurbat4 |
The Family of NoSQL DBs
Key-values Stores
Hash table where there is a unique key and a pointer to a particular item of data.
Focus on scaling to huge amounts of data
E.g.Oracle BDB
Column Family Stores
To store and process very large amounts of data distributed over many machines
E.g.Cassandra, HBase
Document Databases
Collections of Key-Value collections
The next level of Key/value, allowing nested values associated with each key.
Appropriate for Web apps.
E.g. CouchDB, MongoDb
Graph Databases
Bases on property-graph model
Appropriate for Social networking, Recommendations
E.g. Neo4J, InfiniteGraph
Introduction to MongoDB
University ofTurbat5 |
MongoDB
 Document-oriented NoSQL database
 Schema-free
 Based on Binary JSON; BSON
 Organized in Group of Documents  Collections
 Informal namespacing
 Auto-Sharding in order to scale horizontally
 Simple query language. Rich, document-based queries.
 Map/Reduce support
 Open Source
Introduction to MongoDB
University ofTurbat6 |
MongoDB
Who uses MongoDB
Weather Channel
ADP
Expedia
SourceForge
Bosch
Introduction to MongoDB
7
Document store
RDBMS MongoDB
Database Database
Table,View Collection
Row Document (JSON,
BSON)
Column Field
Index Index
Join Embedded Document
Foreign Key Reference
Partition Shard
University ofTurbatIntroduction to MongoDB
Document store
RDBMS MongoDB
Database Database
Table,View Collection
Row Document (JSON,
BSON)
Column Field
Index Index
Join Embedded Document
Foreign Key Reference
Partition Shard
> db.user.findOne({age:39})
{
"_id" : ObjectId("5114e0bd42…"),
"first" : "John",
"last" : "Doe",
"age" : 39,
"interests" : [
"Reading",
"Mountain Biking ]
"favorites": {
"color": "Blue",
"sport": "Soccer"}
}
University ofTurbatIntroduction to MongoDB
University ofTurbat9 |
Installation
University ofTurbat10 |
Installation of MongoDB
How to Download Setup
Installation of MongoDB
 Open a browser
 Write mongodb
 Click MongoDB webite with https://www.mongodb.com
University ofTurbat11 |
Installation of MongoDB
Installation of MongoDB
 Click on Get MongoDB buttion
University ofTurbat12 |
Installation of MongoDB
Installation of MongoDB
 Click on Community Server button in the menu
 Choose an Operating System
 Click on D OWNLOAD button
University ofTurbat13 |
Installation of MongoDB
Installation of MongoDB
 After downloading MongoDB then double click on the setup
 While installing,Accept terms and License Agreement,
 Then click next
University ofTurbat14 |
Installation of MongoDB
Installation of MongoDB
 Click on the Complete button
University ofTurbat15 |
Installation of MongoDB
Installation of MongoDB
 Click on the next button
University ofTurbat16 |
Installation of MongoDB
Installation of MongoDB
 Uncheck “Install MongoDB Compass” then click Next button
University ofTurbat17 |
Installation of MongoDB
Installation of MongoDB
 After installation, copy the path C:Program
FilesMongoDBServer4.0bin
University ofTurbat18 |
Installation of MongoDB
Installation of MongoDB
 Then go toThis Pc properties then click “Advance system setting” button
 Then click on “EnvironmentVariable” to paste the path
University ofTurbat19 |
Installation of MongoDB
Installation of MongoDB
 After, go to c:Program Files
 Create a folder named Data
 Create another folder named db in Data folder
University ofTurbat20 |
Installation of MongoDB
Installation of MongoDB
 Then Open cmd ,Write the command “mongod”
University ofTurbat21 |
Installation of MongoDB
Installation of MongoDB
 Again Open cmd ,Write the command “mongo”
University ofTurbat22 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat23 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat24 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat25 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat26 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat27 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat28 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat29 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat30 |
Installation of MongoDB
Installation of MongoDB
 Go to https://robomongo.org
University ofTurbat31 |
MongoDB Data Modelling
University ofTurbat32 |
Schema Design
 Relational
MongoDB Data Modelling
 MongoDB
• Tabular Data-Tables,Rows and Columns
• Normalized- Flatten your data
• Columns with simple values(int, varchar)
• Related rows with foreign key references
• Indexes on values
• Databases > Collections > Documents
• Documents are monolithic units
• Embedded complex data structures
• No joins- repeat data for faster access
• Difficult to relate documents together
University ofTurbat33 |
Flexible Schema and Documents structure
 Flexible Schema
 Document Structure
MongoDB Data Modelling
1. Reference 2. Embedded Data
University ofTurbat34 |
Atomic operations
 Atomic Operations
• supports atomic operations executed against single documents
• An atomic operation is a set of operations that appears to be merely one single
operation to the rest of the system
• It will have positive or negative results
Examples:
1. $set: Sets a particular value.
2. $unset: Removes a particular value.
3.$inc: Increments a particular value by a certain amount.
MongoDB Data Modelling
University ofTurbat35 |
MongoDB Data Modelling
 Data types
1. String
2.Integer
3.Boolean
4.Double
5.Max/Min keys
6.Array
7.TimeStamp
8.Object
9.Null
10.Symbol
11.Date
12.Object ID
13.Binary Data
14.Regular Expression
15.JavaScript Code
MongoDB Data Modelling
University ofTurbat36 |
Some ConsiderationsWhile Designing Schema
 Considerations
• Design your schema according to user requirements.
• Combine objects into one document if you will use them together. Otherwise
separate them (but make sure there
• should not be need of joins.
• Duplicate the data (but limited) because disk space is cheap as compare to
compute time.
• Do joins while write, not on read.
• Optimize your schema for most frequent use cases.
MongoDB Data Modelling
University ofTurbat37 |
Creating Database
 Mongodb Shell
 The use command
• Database is create using “use ” command (use DatabaseName)
Example:
MongoDB Data Modelling
>use UOTDatabase
Switched to db UOTDatabase
University ofTurbat38 |
Creating Database
 commands
• use DatabaseName : Creating Database
• db: Currently selected Databse
• showdb: Shows all Database
MongoDB Data Modelling
University ofTurbat39 |
Creating collection and document
 Creating collection and document
• db.movie.insert({"name":"tutorials point"})
MongoDB Data Modelling
University ofTurbat40 |
CRUD
University ofTurbat41 |
MongoDB CRUD Operations
CRUD Operations
 Create Operations
 Read Operations
 Update Operations
 Delete Operations
MongoDB CRUDOperations
University ofTurbat42 |
MongoDB CRUD Operations
Create Operations
 Create Or Insert operations Add A New DocumentTo A Collection
 MongoDB providesThe Following Methods to InsertA Document
1. Db.collection.insertone()
2. Db.collection.insertmany()
MongoDB CRUDOperations
University ofTurbat43 |
MongoDB CRUD Operations
READ Operations
 Read operations retrieves documents from a collection
 Methods For Reading Or Finding a document…
1. db.collection.find()
MongoDB CRUDOperations
University ofTurbat44 |
MongoDB CRUD Operations
UPDATE Operations
 Update operations modify existing documents in a collection.
 Methods For Updating…….
1. db.collection.updateone()
2. db.collection.updatemany()
3. db.collection.replaceone()
MongoDB CRUDOperations
University ofTurbat45 |
MongoDB CRUD Operations
DELETE Operations
 Delete operations remove documents from a collection
 Methods For Deleting Documents…
1. db.collection.deleteone()
2. db.collection.deletemany()
MongoDB CRUDOperations
University ofTurbat46 |
Thank you
Any Questions

Presentation mongodb

  • 1.
    Presented by: GroupMembers Zubair Ahmed, Jameel Ahmed, Naeem Jan and Hassam Hamid Instructor: Mr. Mukhtar Hussain Class: BSCS 8th (2015-2018) Presented by: Group Members Date:Tuesday, September 11, 2018 Department: Computer Science
  • 2.
    University ofTurbat2 | PresentationTasks 1)Introduction to MongoDB By Jameel Ahmed 2) Installing MongoDB By Naeem Jan 3) MongoDB Data Modelling By Zubair Ahmed 4) MongoDB CRUD Operations By Hassam Hamid
  • 3.
  • 4.
    University ofTurbat4 | TheFamily of NoSQL DBs Key-values Stores Hash table where there is a unique key and a pointer to a particular item of data. Focus on scaling to huge amounts of data E.g.Oracle BDB Column Family Stores To store and process very large amounts of data distributed over many machines E.g.Cassandra, HBase Document Databases Collections of Key-Value collections The next level of Key/value, allowing nested values associated with each key. Appropriate for Web apps. E.g. CouchDB, MongoDb Graph Databases Bases on property-graph model Appropriate for Social networking, Recommendations E.g. Neo4J, InfiniteGraph Introduction to MongoDB
  • 5.
    University ofTurbat5 | MongoDB Document-oriented NoSQL database  Schema-free  Based on Binary JSON; BSON  Organized in Group of Documents  Collections  Informal namespacing  Auto-Sharding in order to scale horizontally  Simple query language. Rich, document-based queries.  Map/Reduce support  Open Source Introduction to MongoDB
  • 6.
    University ofTurbat6 | MongoDB Whouses MongoDB Weather Channel ADP Expedia SourceForge Bosch Introduction to MongoDB
  • 7.
    7 Document store RDBMS MongoDB DatabaseDatabase Table,View Collection Row Document (JSON, BSON) Column Field Index Index Join Embedded Document Foreign Key Reference Partition Shard University ofTurbatIntroduction to MongoDB
  • 8.
    Document store RDBMS MongoDB DatabaseDatabase Table,View Collection Row Document (JSON, BSON) Column Field Index Index Join Embedded Document Foreign Key Reference Partition Shard > db.user.findOne({age:39}) { "_id" : ObjectId("5114e0bd42…"), "first" : "John", "last" : "Doe", "age" : 39, "interests" : [ "Reading", "Mountain Biking ] "favorites": { "color": "Blue", "sport": "Soccer"} } University ofTurbatIntroduction to MongoDB
  • 9.
  • 10.
    University ofTurbat10 | Installationof MongoDB How to Download Setup Installation of MongoDB  Open a browser  Write mongodb  Click MongoDB webite with https://www.mongodb.com
  • 11.
    University ofTurbat11 | Installationof MongoDB Installation of MongoDB  Click on Get MongoDB buttion
  • 12.
    University ofTurbat12 | Installationof MongoDB Installation of MongoDB  Click on Community Server button in the menu  Choose an Operating System  Click on D OWNLOAD button
  • 13.
    University ofTurbat13 | Installationof MongoDB Installation of MongoDB  After downloading MongoDB then double click on the setup  While installing,Accept terms and License Agreement,  Then click next
  • 14.
    University ofTurbat14 | Installationof MongoDB Installation of MongoDB  Click on the Complete button
  • 15.
    University ofTurbat15 | Installationof MongoDB Installation of MongoDB  Click on the next button
  • 16.
    University ofTurbat16 | Installationof MongoDB Installation of MongoDB  Uncheck “Install MongoDB Compass” then click Next button
  • 17.
    University ofTurbat17 | Installationof MongoDB Installation of MongoDB  After installation, copy the path C:Program FilesMongoDBServer4.0bin
  • 18.
    University ofTurbat18 | Installationof MongoDB Installation of MongoDB  Then go toThis Pc properties then click “Advance system setting” button  Then click on “EnvironmentVariable” to paste the path
  • 19.
    University ofTurbat19 | Installationof MongoDB Installation of MongoDB  After, go to c:Program Files  Create a folder named Data  Create another folder named db in Data folder
  • 20.
    University ofTurbat20 | Installationof MongoDB Installation of MongoDB  Then Open cmd ,Write the command “mongod”
  • 21.
    University ofTurbat21 | Installationof MongoDB Installation of MongoDB  Again Open cmd ,Write the command “mongo”
  • 22.
    University ofTurbat22 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 23.
    University ofTurbat23 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 24.
    University ofTurbat24 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 25.
    University ofTurbat25 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 26.
    University ofTurbat26 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 27.
    University ofTurbat27 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 28.
    University ofTurbat28 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 29.
    University ofTurbat29 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 30.
    University ofTurbat30 | Installationof MongoDB Installation of MongoDB  Go to https://robomongo.org
  • 31.
  • 32.
    University ofTurbat32 | SchemaDesign  Relational MongoDB Data Modelling  MongoDB • Tabular Data-Tables,Rows and Columns • Normalized- Flatten your data • Columns with simple values(int, varchar) • Related rows with foreign key references • Indexes on values • Databases > Collections > Documents • Documents are monolithic units • Embedded complex data structures • No joins- repeat data for faster access • Difficult to relate documents together
  • 33.
    University ofTurbat33 | FlexibleSchema and Documents structure  Flexible Schema  Document Structure MongoDB Data Modelling 1. Reference 2. Embedded Data
  • 34.
    University ofTurbat34 | Atomicoperations  Atomic Operations • supports atomic operations executed against single documents • An atomic operation is a set of operations that appears to be merely one single operation to the rest of the system • It will have positive or negative results Examples: 1. $set: Sets a particular value. 2. $unset: Removes a particular value. 3.$inc: Increments a particular value by a certain amount. MongoDB Data Modelling
  • 35.
    University ofTurbat35 | MongoDBData Modelling  Data types 1. String 2.Integer 3.Boolean 4.Double 5.Max/Min keys 6.Array 7.TimeStamp 8.Object 9.Null 10.Symbol 11.Date 12.Object ID 13.Binary Data 14.Regular Expression 15.JavaScript Code MongoDB Data Modelling
  • 36.
    University ofTurbat36 | SomeConsiderationsWhile Designing Schema  Considerations • Design your schema according to user requirements. • Combine objects into one document if you will use them together. Otherwise separate them (but make sure there • should not be need of joins. • Duplicate the data (but limited) because disk space is cheap as compare to compute time. • Do joins while write, not on read. • Optimize your schema for most frequent use cases. MongoDB Data Modelling
  • 37.
    University ofTurbat37 | CreatingDatabase  Mongodb Shell  The use command • Database is create using “use ” command (use DatabaseName) Example: MongoDB Data Modelling >use UOTDatabase Switched to db UOTDatabase
  • 38.
    University ofTurbat38 | CreatingDatabase  commands • use DatabaseName : Creating Database • db: Currently selected Databse • showdb: Shows all Database MongoDB Data Modelling
  • 39.
    University ofTurbat39 | Creatingcollection and document  Creating collection and document • db.movie.insert({"name":"tutorials point"}) MongoDB Data Modelling
  • 40.
  • 41.
    University ofTurbat41 | MongoDBCRUD Operations CRUD Operations  Create Operations  Read Operations  Update Operations  Delete Operations MongoDB CRUDOperations
  • 42.
    University ofTurbat42 | MongoDBCRUD Operations Create Operations  Create Or Insert operations Add A New DocumentTo A Collection  MongoDB providesThe Following Methods to InsertA Document 1. Db.collection.insertone() 2. Db.collection.insertmany() MongoDB CRUDOperations
  • 43.
    University ofTurbat43 | MongoDBCRUD Operations READ Operations  Read operations retrieves documents from a collection  Methods For Reading Or Finding a document… 1. db.collection.find() MongoDB CRUDOperations
  • 44.
    University ofTurbat44 | MongoDBCRUD Operations UPDATE Operations  Update operations modify existing documents in a collection.  Methods For Updating……. 1. db.collection.updateone() 2. db.collection.updatemany() 3. db.collection.replaceone() MongoDB CRUDOperations
  • 45.
    University ofTurbat45 | MongoDBCRUD Operations DELETE Operations  Delete operations remove documents from a collection  Methods For Deleting Documents… 1. db.collection.deleteone() 2. db.collection.deletemany() MongoDB CRUDOperations
  • 46.

Editor's Notes

  • #8 Javascript
  • #9 Flexible schema Javascript