KEMBAR78
Introduction to MongoDB | ODP
Dineesha Suraweera
Developed by 10gen in 2007
Published as GNU Affero General Public
License and the Apache License
What is mongoDB?

Open Source

Document Oriented database

Cross- Platform

No - SQL
Document Oriented vs Relational
Databases
Schema less : MongoDB is document database in which one collection holds different
different documents. Number of fields, content and size of the document can be differ from
one document to another.
Structure of a single object is clear
No complex joins
Deep query-ability. MongoDB supports dynamic queries on documents using a document-
based query language that's nearly as powerful as SQL
Tuning
Ease of scale-out: MongoDB is easy to scale
Conversion / mapping of application objects to database objects not needed
Uses internal memory for storing the (windowed) working set, enabling faster access of data
RDBMS mongoDB
Database Database
Table Collection
Tuple/Row Document
column Field
Table Join Embedded Documents
Primary Key Primary Key (Default key _id
provided by mongodb itself)
Features
Ad hoc queries
Indexing
Replication
Load balancing
File storage
Aggregation
Server-side JavaScript execution
Capped collections
MongoDB Architecture
MongoDB Storage Engines
Horizontally Scalable Architecture
Sharding
Replication
Document Storage
Document are stored in BSON(Binary JSON)
BSON - binary serialization of json like objects.

Any valid JSON can easily imported and queried.

MongoDB understand JSON natively.
Create Database
use DATABASE_NAME
db – show currently selected database.
show dbs – output database list
Create Collection
db.createCollection(name, options)
db.createCollection(
"mycol", { capped : true,
autoIndexID : true,
Size : 6142800,
max : 10000
} )
Insert Document
db.COLLECTION_NAME.insert(document)
db.mycol.insert({
_id: ObjectId(7df78ad8902c),
title: 'MongoDB Overview',
description: 'MongoDB is no sql database',
tags: ['mongodb', 'database', 'NoSQL'],
likes: 100
})
Query Document
db.COLLECTION_NAME.find()
(formatted way)
db.COLLECTION_NAME.find().pretty()
Indexing
db.COLLECTION_NAME.ensureIndex({KEY:1})
db.mycol.ensureIndex({"title":1,"description":-1})
Demo
Non-Functional Features

Easy readability

High performance

High availability

Easy scalability

Aggregation
Stores data as documents or objects
(everyone works with objects)
Disadvantages or less good at ????
High transactions
Problems that require SQL
Other No-SQL databases
Cassandra
Accumulo
Cloudata
HPCC
ConcourseDB
Druid
SpliceMachine
Where to use ???
Big Data
Content Management and Delivery
Mobile and Social Infrastructure
User Data Management
Data Hub
Users of MongoDB
Adobe
Ebay
LinkedIn
McAfee
SAP
Yandex
Thank You!

Introduction to MongoDB