Presented By:-
Jayesh Bharda (116373)
Bhavesh Sarvaiya (115347)
Ketan Navadiya (115331)
∗ What is NoSQL?
∗ What is MongoDB?
∗ Database
∗ Collection
∗ Document
∗ MongoDB to SQL Terminology
∗ Advantages of MongoDB over RDBMS
∗ CRUD Operation
∗ References
Topics
∗ MongoDB is a No SQL database.
∗ MongoDB is a cross-platform, document oriented
database that provides, high performance, high
availability, and easy scalability.
∗ MongoDB works on concept of collection and
document.
∗ It is written in C++.
What is MongoDB?
∗ Database is a physical container for collections.
∗ Each database gets its own set of files on the file
system.
∗ A single MongoDB server typically has multiple
databases.
Database
∗ Collection is a group of MongoDB documents.
∗ It is the equivalent of an RDBMS table.
∗ A collection exists within a single database.
∗ Documents within a collection can have different
fields.
∗ Typically, all documents in a collection are of similar
or related purpose.
Collection
∗ Documents exist inside a collection.
∗ Documentation can almost be thought of as rows in a
sql database, except they have key difference:
∗ Documents are schema-less
∗ Document used JSON Syntax
∗ The maximum size of a document is 16 megabytes
∗ Not Relational
Document
MongoDB SQL
database database
collection table
document record (row)
field column
embedded documents join
primary key (Default key _id provided
by mongodb itself)
primary key (user designated)
Index index
MongoDB to SQL Terminology
∗ Schema less − MongoDB is a document database in
which one collection holds different documents.
Number of fields, content and size of the document
can differ from one document to another.
• Structure of a single object is clear.
• No complex joins.
∗ Ease of scale-out
• Conversion/mapping of application objects to database
objects not needed.
Advantages of MongoDB over
RDBMS
∗ Document Oriented Storage − Data is stored in the
form of JSON style documents.
∗ Index on any attribute
∗ Replication and high availability
∗ Rich queries
∗ Fast in-place updates
∗ Professional support by MongoDB
Why Use MongoDB?
∗ Big Data
∗ Content Management and Delivery
∗ Mobile and Social Infrastructure
∗ User Data Management
∗ Data Hub
Where to Use MongoDB?
User of MongoDB
∗ The use Command
• MongoDB use DATABASE_NAME is used to create database.
∗ Syntax
• use DATABASE_NAME
∗ Example
• use mydb
∗ To check your currently selected database
• Db
∗ To check your databases list
• show dbs
∗ To drop a existing database
• db.dropDatabase()
• This will delete the selected database
Create Database
∗String
∗Integer
∗Boolean
∗Double
∗Min/Max key
∗Array
∗Timestamp
∗Object
∗Null
∗Date
∗Objecy ID
Datatypes
∗ The createCollection() Method
• MongoDB db.createCollection(name, options) is used to
create collection.
∗ Syntax
• db.createCollection(name, options)
∗ Example
• db.createCollection(“student")
• db.createCollection("mycol", { capped : true, autoIndexId :
true, size : 6142800, max : 10000 } )
Create Collection
∗ In MongoDB, you don't need to create collection.
∗ MongoDB creates collection automatically, when you
insert some document.
• db.stud.insert({"name" :”bhavesh"})
∗ db.collection.drop()
• db.stud.drop()
Continue…
∗ To insert data into MongoDB collection, to use
MongoDB's insert() or save() method.
∗ Syntax
• db.COLLECTION_NAME.insert(document)
∗ Example
• db.student.insert({no:”115347”,name:”bhavesh”,address:{t
o:”ayavej”,taluka:”jesar”,dist:”Bhavnagar”,pin:”364510”}})
Insert Document
∗ The find() Method
• To query data from MongoDB collection, you need to
use MongoDB's find()method.
∗ Example
• db.student.find()
∗ limit() Method
• db.student. find().limit(1)
Query Document
∗ skip() method
• In MongoDB, skip() method is used to skip the document. It is
used with find() and limit() methods.
∗ Syntax
• db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER)
∗ Example
• db.student.find().limit(1).skip(2)
∗ sort() method
• db.COLLECTION_NAME.find().sort({KEY:1})
• db.student.find().sort(“name”:-1)
Continue…
∗ Update() method is used to update or modify the
existing documents of a collection.
∗ Syntax:
• db.COLLECTION_NAME.update(SELECTIOIN_CRITERIA,
UPDATED_DATA)
∗ Example
• db.student.find()
Update documents
∗ db.student.update({name:”bhavesh”},{$set:{name:”b
havo”}})
∗ db.student.find()
Continue…
∗ remove() method is used to remove a document from
the collection.
∗ Syntax
• db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)
∗ Example
• db.student.remove({name:”bhavo”})
Delete Document
∗ https://docs.mongodb.com
∗ https://www.tutorialspoint.com
∗ https://www.javatpoint.com
References
Thank You

Mongo db nosql (1)

  • 1.
    Presented By:- Jayesh Bharda(116373) Bhavesh Sarvaiya (115347) Ketan Navadiya (115331)
  • 2.
    ∗ What isNoSQL? ∗ What is MongoDB? ∗ Database ∗ Collection ∗ Document ∗ MongoDB to SQL Terminology ∗ Advantages of MongoDB over RDBMS ∗ CRUD Operation ∗ References Topics
  • 3.
    ∗ MongoDB isa No SQL database. ∗ MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. ∗ MongoDB works on concept of collection and document. ∗ It is written in C++. What is MongoDB?
  • 4.
    ∗ Database isa physical container for collections. ∗ Each database gets its own set of files on the file system. ∗ A single MongoDB server typically has multiple databases. Database
  • 5.
    ∗ Collection isa group of MongoDB documents. ∗ It is the equivalent of an RDBMS table. ∗ A collection exists within a single database. ∗ Documents within a collection can have different fields. ∗ Typically, all documents in a collection are of similar or related purpose. Collection
  • 6.
    ∗ Documents existinside a collection. ∗ Documentation can almost be thought of as rows in a sql database, except they have key difference: ∗ Documents are schema-less ∗ Document used JSON Syntax ∗ The maximum size of a document is 16 megabytes ∗ Not Relational Document
  • 7.
    MongoDB SQL database database collectiontable document record (row) field column embedded documents join primary key (Default key _id provided by mongodb itself) primary key (user designated) Index index MongoDB to SQL Terminology
  • 8.
    ∗ Schema less− MongoDB is a document database in which one collection holds different documents. Number of fields, content and size of the document can differ from one document to another. • Structure of a single object is clear. • No complex joins. ∗ Ease of scale-out • Conversion/mapping of application objects to database objects not needed. Advantages of MongoDB over RDBMS
  • 9.
    ∗ Document OrientedStorage − Data is stored in the form of JSON style documents. ∗ Index on any attribute ∗ Replication and high availability ∗ Rich queries ∗ Fast in-place updates ∗ Professional support by MongoDB Why Use MongoDB?
  • 10.
    ∗ Big Data ∗Content Management and Delivery ∗ Mobile and Social Infrastructure ∗ User Data Management ∗ Data Hub Where to Use MongoDB?
  • 11.
  • 12.
    ∗ The useCommand • MongoDB use DATABASE_NAME is used to create database. ∗ Syntax • use DATABASE_NAME ∗ Example • use mydb ∗ To check your currently selected database • Db ∗ To check your databases list • show dbs ∗ To drop a existing database • db.dropDatabase() • This will delete the selected database Create Database
  • 13.
  • 14.
    ∗ The createCollection()Method • MongoDB db.createCollection(name, options) is used to create collection. ∗ Syntax • db.createCollection(name, options) ∗ Example • db.createCollection(“student") • db.createCollection("mycol", { capped : true, autoIndexId : true, size : 6142800, max : 10000 } ) Create Collection
  • 15.
    ∗ In MongoDB,you don't need to create collection. ∗ MongoDB creates collection automatically, when you insert some document. • db.stud.insert({"name" :”bhavesh"}) ∗ db.collection.drop() • db.stud.drop() Continue…
  • 16.
    ∗ To insertdata into MongoDB collection, to use MongoDB's insert() or save() method. ∗ Syntax • db.COLLECTION_NAME.insert(document) ∗ Example • db.student.insert({no:”115347”,name:”bhavesh”,address:{t o:”ayavej”,taluka:”jesar”,dist:”Bhavnagar”,pin:”364510”}}) Insert Document
  • 17.
    ∗ The find()Method • To query data from MongoDB collection, you need to use MongoDB's find()method. ∗ Example • db.student.find() ∗ limit() Method • db.student. find().limit(1) Query Document
  • 18.
    ∗ skip() method •In MongoDB, skip() method is used to skip the document. It is used with find() and limit() methods. ∗ Syntax • db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER) ∗ Example • db.student.find().limit(1).skip(2) ∗ sort() method • db.COLLECTION_NAME.find().sort({KEY:1}) • db.student.find().sort(“name”:-1) Continue…
  • 19.
    ∗ Update() methodis used to update or modify the existing documents of a collection. ∗ Syntax: • db.COLLECTION_NAME.update(SELECTIOIN_CRITERIA, UPDATED_DATA) ∗ Example • db.student.find() Update documents
  • 20.
  • 21.
    ∗ remove() methodis used to remove a document from the collection. ∗ Syntax • db.COLLECTION_NAME.remove(DELLETION_CRITTERIA) ∗ Example • db.student.remove({name:”bhavo”}) Delete Document
  • 22.
  • 23.