www.coba.unr.edu

Report
Introduction to
MongoDB
{ "name": "Devyani Tanna"}
slides.com/chinu/mongodb
Overview
•
•
•
NoSQL
 Why use NoSQL database?
 Categories
MongoDB
 Installation
 Concept Mapping
 Database level commands
 Collection level commands
 Schema at application level
Questions?
NoSQL
No, SQL!
Categories of NoSQL
Document Store

MongoDB

CouchDB
Graph

Neo4j
Key-Value Store

Amazon - DynamoDB

LinkedIn - Voldemort Project

Riak
Tabular

Google - BigTable

Facebook - Cassandra (now Apache Project)
Why use NoSQL Database?
Missing:

No Joins
o They are too expensive!

No Complex Transactions

No Constraint Support
o Not at database level. Added at application level.
Extra:

Query Language

Fast Performance

Horizontal Scalability
Horizontal Scalability
MongoDB (from "humongous") is a
scalable, high-performance, open
source, schema-free, documentoriented database.
-mongodb.org
Installation
•
•
Takes less than 5 minutes
try.mongodb.org
Concept Mapping
_id
(Like Primary Key in RDBMS)
•
•
•
•
•
Special Key
Present in all documents (Rows)
Unique across a collection (Table)
Any type you want
24 byte hex string, 12 byte binary string, or a number
Document
(Like Row in RDBMS)
Note: Fields ("Key": "Value") have Primitive types +
arrays, documents
Collection
(Like Table in RDBMS)
Index
B- Tree
Commands
Database Level
•
•
•
•
mongod (Starts the server)
mongo (Connects to server)
show dbs
use <db>
Commands
Collection Level
1. Show Collections - Lists collections in a current
database
Commands
Collection Level
2. db.collections.findOne() - Displays first document in a
collection
3.db.collection.find() - Displays all documents in a
collection
Commands
Collection Level
4.
db.collection.someFunction.forEach(printjson) - Prints
information in a easy to read format.
Commands
Collection Level
5. db.collection.count() - Number of documents in a
collection
6. db.collection.update(object) - Used to update a specific
document
7. db.collection.insert(object) - Used to insert a specific
document into a collection
Commands
Collection Level
8. db.collection.save(object) - Save a new document in a
collection
Commands
Collection Level
9. db.collection.find( { }, { field: 0 or 1}) - Specify
which fields to display.
Commands
Collection Level
10. Example of two queries.
Commands
Collection Level - Last One!!!!
11. Example of querying sub-document with dot notation.
Schema at Application Level
Resources
•
MongoDB Commands
o http://docs.mongodb.org/manual/reference/comman
•
•
d/
MongoDB Tutorials (Part 1 thru 14) Best Videos
o https://www.youtube.com/watch?v=UA8q6kS8uaE
NoSQL Style (Gangnam Style Parody for Geeks)
o https://www.youtube.com/watch?v=qpK0WAuyOl4
Questions?

similar documents