KEMBAR78
Mongodb: Senthil Kumar A | PDF | Mongo Db | Databases
0% found this document useful (0 votes)
63 views21 pages

Mongodb: Senthil Kumar A

MongoDB is a document-oriented, leading NoSQL database that uses JSON-like documents with dynamic schemas, indexing, replication and sharding. It provides rich querying, map-reduce functions, file storage, monitoring and professional support. The core components are the mongod database server, mongo interactive shell, and mongos sharding router. MongoDB stores data as JSON-like documents which it calls BSON, and is useful for applications like content management, gaming, mobile and real-time analytics.

Uploaded by

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

Mongodb: Senthil Kumar A

MongoDB is a document-oriented, leading NoSQL database that uses JSON-like documents with dynamic schemas, indexing, replication and sharding. It provides rich querying, map-reduce functions, file storage, monitoring and professional support. The core components are the mongod database server, mongo interactive shell, and mongos sharding router. MongoDB stores data as JSON-like documents which it calls BSON, and is useful for applications like content management, gaming, mobile and real-time analytics.

Uploaded by

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

training@datadotz.

com

MONGODB
Senthil Kumar A
training@datadotz.com

What is MongoDB?
• Document-oriented, Leading NoSQL Database
• Uses JSON (MongoDB calls the format BSON)
• Open Source
• Schema less

• Full Index Support


• Index on any attribute

• Replication and High Availability


• Across networks for Scaling

• Auto Sharding
• Horizontal Scaling
training@datadotz.com

Cont.
• Querying
• Rich set of Queries

• Map-Reduce
• Aggregation and Data Processing

• Grid FS
• Stores files of any size

• MongoDB Management Services (MMS)


• Monitoring Tool

• Professional Support
training@datadotz.com

MongoDB with Relational DB

Memcached
Scalability and Performance

MongoDB
Key-Value Storage

Joins
&
Transactions

RDBMS

Functionality
training@datadotz.com

What MongoDB is good at


• Documents /content Management
• Gaming
• Mobile & Location services
• Agile Developments
• Real-Time Stats/ Analysis and more
training@datadotz.com

Basic Components
• mongod
• The Database Server
• mongo
• The Interactive Shell
• mongos
• The Sharding Router

MondoD Mongo
The Database The Interactive
Server Shell

MongoS
The Sharding
Router
training@datadotz.com

Cont.
• MongoD
• The core database process
• The primary daemon process for the MongoDB system.
• Handles data requests
• Manages data format
• Performs background management operations.

• Mongo
• Interactive JavaScript shell Interface
• Powerful Interface to test queries, operations directly with
database
• Provides a functional JavaScript environment for use with a
MongoDB
training@datadotz.com

Cont.
• MongoS
• Controller/query Router for shared cluster
• “MongoDB Shard,” is a routing service for MongoDB shard
configurations
• Load balancing process between application and MongoDB

• Determines the location of this data in the sharded cluster

• Interacts with the client in order to abstract away the actual cluster
of mongod servers
training@datadotz.com

General Architecture
CLIENT

mongoS mongoS ….
CONFIG SERVERS

mongoD
mongo mongo
mongoD

mongo ….
mongo

mongo

mongo
mongoD
training@datadotz.com

JSON
• JSON
• JavaScript Object Notification

• Language independent (C, C++, C#, Java, Python, Perl…)

• Easy for humans to read and write

• A JSON document is a collection of fields and values in a structured


format.
training@datadotz.com

Cont.
• Two Structures
• A collection of name/value pairs.
• Realized as an object, record, struct, dictionary, hash table, keyed list.
• { “Name”: “Amudhan” , “Company”: “DataDotz” }

• An ordered list of values.


• In most languages, this is realized as an array, vector, list, or sequence.
• { “employees”: *
{ “Name”: “Amudhan” , “Company”: “DataDotz” }
{ “Name”: “Gowtham” , “Company”: “DataDotz” }
{ “Name”: “Saravanan” , “Company”: “DataDotz” }
]}
training@datadotz.com

BSON
• BSON
• Binary JSON
• Binary form of representing simple data structures and arrays
• Known as objects or documents in MongoDB

• Stored as single entity (Document) with key/value pairs

• Schema less

• Language independent (C, C++, C#, Java, Python, Perl…)


training@datadotz.com

Cont.
• Efficiency
• Encoding and Decoding is quick
• Occupies less storage space
• High Scan speed

• In-place Updating
• Modify part of object without re-serializing whole object
training@datadotz.com

Installation
• Download mongodb-linux-*.tar.gz
• tar –zxvf mongodb-linux-*.tar.gz
• sudo apt-get update
• sudo apt-get install mongodb-server
• sudo mkdir /data
• sudo mkdir /data/db
• sudo chmod -R 777 /data/*
• cd mongodb-linux-x86_64-2.6.0
• bin/mongod
• bin/mongo
training@datadotz.com

Collections
• Document based Database
• A record is a document/ data structure
• Composed of field and value pairs

{
name: “amudhan”, field: value
drug name: “avil”, field: value
tot_amt: 100 field: value
}

• Value may include- other documents, arrays, array of documents.


training@datadotz.com

SQL to MongoDB
MySQL Term MongoDB Term/Concept
Database Database
Table Collection
Index Index
Row BSON document
Column BSON field
Join Embedding and linking
Primary _id field
Group by Aggregation
training@datadotz.com

CRUD Operations
• CREATE
Collection Document Collection

db.test.insert(
{ { pid: 1, name: amudhan, dr…}
{ pid: 2, name: gowtham, dr…}
name: “amudhan”,
{ pid: 3, name: saravanan, d…}
drug name: “avil”, { pid: 4, name: senthil, drug …}
tot_amt: 100 { pid: 5, name: siva, drug: m…}

}
Document
db.test.insert({pid:'1',name:'amudhan',drug:'avil',t
ot_amt:100})
)
db.test.insert({pid:'2',name:'gowtham',drug:'Parac
etamol',tot_amt:200})
db.test.insert({pid:'3',name:'saravanan',drug:'met
acin',tot_amt:300})
training@datadotz.com

Cont.
• READ
Collection

db.test.find( { drug: ’metacin’ } ).limit(1)

Collection Query Criteria Modifier

{ pid: 1, name: amudhan…}


{ pid: 2, name: gowtham…} { pid: 3, name: sara…} { pid: 3, name: sara…}
{ pid: 3, name: saravana…} { pid: 5, name: siva…}
{ pid: 4, name: senthil, d…}
{ pid: 5, name: siva, drug…}
Results

test
training@datadotz.com

Cont.
• UPDATE
Collection

db.test.update({name:'amudhan'}, {$set : {drug: 'avil', pid: ‘6'}})

Collection Query Criteria Modifier

{ pid: 1, name: amudhan…} { pid: 6, name: amud…}


{ pid: 2, name: gowtham…} { pid: 2, name: gowt…}
{ pid: 1, name: amu…}
{ pid: 3, name: saravana…} { pid: 3, name: sarav…}
{ pid: 4, name: senthil, d…} { pid: 4, name: senth…}
{ pid: 5, name: siva, drug…} { pid: 5, name: siva, …}

test Results
training@datadotz.com

Cont.
• DELETE
Collection

db.test.remove({name:'amudhan'} )

Collection Query Criteria Modifier

{ pid: 1, name: amudhan…} { pid: 2, name: gowt…}


{ pid: 2, name: gowtham…} { pid: 3, name: sarav…}
{ pid: 1, name: amu…}
{ pid: 3, name: saravana…} { pid: 4, name: senth…}
{ pid: 4, name: senthil, d…} { pid: 5, name: siva, …}
{ pid: 5, name: siva, drug…}

test Results
training@datadotz.com

THANK YOU

You might also like