Date post: | 11-Jul-2015 |
Category: |
Technology |
Upload: | valeri-karpov |
View: | 845 times |
Download: | 0 times |
MongoDB in 20 MinutesValeri Karpov
Software Engineer, MongoDBwww.thecodebarbarian.com
www.slideshare.net/vkarpov15github.com/vkarpov15
@code_barbarian
*
Who am I?
•CI/NodeJS/Tools Engineer at MongoDB
•Maintainer of mongoose ODM
•Currently working on new mongodb tools
•Contributor to NodeJS and Go drivers
•Princeton CS ‘11
*
MongoDB
The leading NoSQL database
Document Database
Open-SourceGeneral Purpose
*
•Big banks: Goldman Sachs, Citi, DB•News: Business Insider, Forbes, NYT•Hackathon Tools: Trello, Github, Sourceforge•HackPrinceton sponsors: Sailthru, Buzzfeed, Facebook (and MongoDB of course)•Odds are, you have interacted with MongoDB today
Who Uses It?
*
What’s MongoDB About?
*
RDBMS
Store Objects, Not Columns
MongoDB
{
_id : ObjectId("4c4ba5e5e8aabf3"),
employee_name: "Dunham, Justin",
department : "Marketing",
title : "Product Manager, Web",
report_up: "Neray, Graham",
pay_band: “C",
benefits : [
{ type : "Health",
plan : "PPO Plus" },
{ type : "Dental",
plan : "Standard" }
]
}
*
Better Data Locality
High Performance
In-Memory Caching In-Place Updates
*
Scales Vertically and Horizontally
Auto-Sharding
*
Durable
•Automated replication and failover
•Multi-data center support
•Data remains consistent
*
ShellCommand-line shell for interacting directly with database
Write Code in Your Favorite LanguageDriversDrivers for most popular programming languages and frameworks
> db.collection.insert({product:“MongoDB”, type:“Document Database”})> > db.collection.findOne(){
“_id” : ObjectId(“5106c1c2fc629bfe52792e86”),“product” : “MongoDB”“type”: “Document Database”
}
Java
Python
Perl
Ruby
Haskell
JavaScript
*
Talk is Cheap: Lets Hack
•Download MongoDB 2.8.0-rc0 - fresh out of the oven (11/12), still experimental
•Data set: cities in USA with latitude, longitude, population based on 2010 census
•Download from my S3 bucket
•Going to use MongoDB shell to demo some cool MongoDB features
•Can access these features from your language of choice
*
Simple: How many people live in Princeton?
*
Simple: How many towns called Princeton in the US?
*
What are the 3 most populous “Princetons” in the US?
*
Geo: 3 most populous towns within 10 miles of Princeton
*
Geo: Nearest Towns to Princeton that Have “ville” in the name
*
Geo: Nearest Towns to Princeton that Have “ville” in the name
*
Text Search: Most Populous Cities with “Fall” in the name
*
Text Search and Geo Together
*
Aggregation: Transforming Data
•General idea of MongoDB: structure data to fit your use case
•Aggregation framework allows you to take data and transform it to better fit your use case
*
Example: Recreating Cities Data Set
•Cities data set actually transformed from zip codes
*
Example: Recreating Cities Data Set
•General idea to transform zips to cities:
• Group zips by city/state
• Sum up populations
• Take one of the locations
*
Example: Recreating Cities Data Set
*
Outputting Cities Data Set