0% found this document useful (0 votes)
282 views19 pages

Mongo DB

MongoDB is a document-oriented NoSQL database that is simple, dynamic, and scalable. It uses collections and documents rather than tables and rows. Documents are analogous to JSON objects and can contain different field types. MongoDB is installed by downloading the Windows installer from MongoDB's website. It supports replication and sharding for high availability and automatic scaling. While it offers high performance and flexibility with structured, semi-structured and unstructured data, it is not as ACID compliant as relational databases and not recommended for complex transactions.

Uploaded by

Sunil Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
282 views19 pages

Mongo DB

MongoDB is a document-oriented NoSQL database that is simple, dynamic, and scalable. It uses collections and documents rather than tables and rows. Documents are analogous to JSON objects and can contain different field types. MongoDB is installed by downloading the Windows installer from MongoDB's website. It supports replication and sharding for high availability and automatic scaling. While it offers high performance and flexibility with structured, semi-structured and unstructured data, it is not as ACID compliant as relational databases and not recommended for complex transactions.

Uploaded by

Sunil Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

MongoDB

Sunil Sinha
What is MongoDB ?

 Simple
 Dynamic
 Document oriented
 Scalable
 NoSQL database
Object-Oriented
RDBMS Table : Employee

firstname lastname age


Thomas Smith 29

Mongo DB collection : Employee

{
"firstname" : "Thomas",
"lastname" : "Smith",
"age" : 29
}
Terminology and Concepts

RDMBS DB MongoDB
Database Database
Table Collection
Index Index
Row Document
Column Field
Joining Linking & Embedding
Partition Sharding (Range Partition)
Replication ReplSet
Installation
 Visit
https://docs.mongodb.com/manual/installation/.
 Install the Enterprise version of MongoDB.
 Download and run the .msi Windows installer ( with
admin access) from mongodb.org/downloads.
Replication
Sharding
Sharding
Why Mongo DB ?

 high performance
 high availability
 automatic scaling
 simple installation and implementation
 Structured , semi structured and non-structured data
 support Windows, Linux, Mac OS X and Solaris
Cons
 Not strongly ACID-compliant (Atomic, Consistency,
Isolation, Durability)
 Not recommended for Defined Complex transactions
 No function or stored procedure exists
 Not recommended for highly transactional systems
 Not recommended for tightly coupled systems

Machine Learning Basics: 1. General Introduction


Database
 use <DATABASE_NAME>
 show dbs
 db.dropDatabase()
collection
 db.createCollection(name)
 show collections
 db.COLLECTION_NAME.drop()
Insert Document
 db.COLLECTION_NAME.insert(document)
 db.<collection_name>.insert
({
_id: ObjectId(7df78ad8902c),
title: 'MongoDB Overview',
description: 'MongoDB is no sql database',
by: 'tutorials point',
url: 'http://www.tutorialspoint.com',
tags: ['mongodb', 'database', 'NoSQL'],
likes: 100
})
Query Document
 db.COLLECTION_NAME.find()
 db.COLLECTION_NAME.find(<option>)
 db.COLLECTION_NAME.find().limit(1)
 db.COLLECTION_NAME.find().limit(1).pretty()
 db.COLLECTION_NAME.find({$and: [{key1: value1},
{key2:value2}]}).pretty()
 db.COLLECTION_NAME.find({$or: [{key1: value1},
{key2:value2}]}).pretty()
Update Document
 db.COLLECTION_NAME.update({<SELECTION_CRITERI
A>},{$set:{<UPDATED_DATA>}})
 db.COLLECTION_NAME.update({<SELECTION_CRITERI
A>},{$set:{<UPDATED_DATA>}},{multi:true})
 db.COLLECTION_NAME.save({_id:ObjectId(),NEW_DAT
A})
Delete Document
 db.COLLECTION_NAME.remove(DELETION_CRITERIA,1)
 db.COLLECTION_NAME.remove(DELETION_CRITERIA)
 db.COLLECTION_NAME.remove()
Projection
 db.COLLECTION_NAME.find({},{KEY1:1,key2:0})
Limit Records
 db.COLLECTION_NAME.find().limit(NUMBER)
 db.COLLECTION_NAME.find().limit(NUMBER).skip(NU
MBER)
 db.COLLECTION_NAME.find().sort({KEY:1})
The End

You might also like