1. The Trusted Technology Partner in
Business Innovation
August 2010 August 2010 July 2010 June 2010
Ranked as one of the top Ranked as one of the top Named Microsoft Partner of CRN Magazine's list of the
technology solution providers technology solution providers the Year Finalist in 2 separate largest solution providers in
in America by CRN Magazine in America by CRN Magazine categories North America
for the past 4 years. for the past 4 years.
2009 2010 2007 2008
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
2. NoSQL With MongoDB
Select fun, profit from real_world where
relational=false
Nagaraja S
Senior Consultant I
Nagaraja.s@neudesic.com
twitter.com/nagarajshanbhog
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
3. Agenda
• NoSQL!!!! …… ?
• Why NoSQL?
• NoSQL Use Cases
• NoSQL Databases
• Overview on MongoDB
• Set up MongoDB
• DEMO
• MongoDB driver for .net
• DEMO
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
4. NoSQL!!!!....?
• NoSQL != NO SQL
• NOSQL == Not Only SQL
• Subjective term (like Web 2.0)
• Usually do not require a fixed table schema nor do they use the concept of
joins
(Cont…)
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
5. NoSQL!!!....?
• Coined in 1998 by “Carlos Strozzi” to describe a database that did not
expose a SQL interface
• In 2008, Eric Evans Reintroduced the term to describe the growing non-
RDBMS movement
• Broadly refers to a set of data stores that do not use SQL or a relational
model to store data
• Popularized by large web sites such as Google, Facebook, Twitter and Digg
etc...
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
6. Why NoSQL..?
• Modern relational databases simply do not scale to internet proportions
• Sites like Digg,Facebook and Ebay have datasets 10s and 100s of TB large
• ACID support isn’t required for blogs, status updates, product listings etc
• Reduce Object relational impedance
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
7. Why NoSQL..?
• GOOD BAD
• Flexible (Schema-less) Immature
• Very scalable No common standards
• Simple to use and operate Poor transaction support
• Eventually consistent Poor query support
• Cheap New Mindset required
• Suited to web applications
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
8. NoSQL Use Cases
• Good Example
– Logging data Shopping carts
– Favorites Session Data
• Stick with RDBMS
– Transactions (Orders etc.) LOB applications
– Anything involves $$$ Business-critical data
– Reporting
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
9. NoSQL Databases
• XML (myXMLDB, Tamino, Senda)
• Wide Column ( Cassandra, Hbase, Big Table)
• Key/Value (Redis, MemCached with BerkelyDB)
• Graph (neo4j, InfoGrid)
• Document store ( CouchDB, MongoDB)
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
10. Overview On MongoDB
• Open source, Document oriented database
• 10gen corporate entity behind development
• Basics
– Document in a MongoDB database are stored in schema-less collections
– Documents are stored in BSON (Binary JSON)
– JavaScript used to Query and Manipulate collections
– Each item in a collection has a unique (primary) key called an “ObjectID”
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
11. SQL to Mongo Mapping Chart
SQL term Mongo term
Database Databse
Table Collection
Index Index
Row BSON Document
Column BSON Field
Join Embedding and linking
Primary key _id field
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
12. Installing MongoDB on Windows
• Download the binaries from “mongodb.org”
• Create a directory “C:datadb”
• Run “Mongod.exe” from the command line
• Run “Mongo.exe” to execute commands
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services
13. SQL statement Mongo statement
Create table users ( a Number, b Number) Implicit; can also by done by explicit
db.createCollection(”user”)
Insert into users values (4,5) db.users.insert ( { a:3, b:5 } )
Select * from users db.users.find()
SELECT * FROM users WHERE age=33 db.users.find({age:33}).sort({name:1})
ORDER BY name
SELECT a,b FROM users WHERE age=33 db.users.find({age:33}, {a:1,b:1})
SELECT * FROM users WHERE name LIKE db.users.find({name:/Joe/})
"%Joe%"
SELECT * FROM users WHERE name LIKE db.users.find({name:/^Joe/})
"Joe%"
SELECT * FROM users WHERE age>33 AND db.users.find({'age':{$gt:33,$lte:40}})
age<=40
The Trusted Technology Partner in Business Innovation
Products | Consulting Services | Managed Services