+ All Categories
Home > Technology > MongoDB API Talk @ HackPrinceton

MongoDB API Talk @ HackPrinceton

Date post: 11-Jul-2015
Category:
Upload: valeri-karpov
View: 845 times
Download: 0 times
Share this document with a friend
25
MongoDB in 20 Minutes Valeri Karpov Software Engineer, MongoDB www.thecodebarbarian.com www.slideshare.net/vkarpov15 github.com/vkarpov15 @code_barbarian
Transcript
Page 2: MongoDB API Talk @ HackPrinceton

*

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

Page 3: MongoDB API Talk @ HackPrinceton

*

MongoDB

The leading NoSQL database

Document Database

Open-SourceGeneral Purpose

Page 4: MongoDB API Talk @ HackPrinceton

*

•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?

Page 5: MongoDB API Talk @ HackPrinceton

*

What’s MongoDB About?

Page 6: MongoDB API Talk @ HackPrinceton

*

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" }

]

}

Page 7: MongoDB API Talk @ HackPrinceton

*

Better Data Locality

High Performance

In-Memory Caching In-Place Updates

Page 8: MongoDB API Talk @ HackPrinceton

*

Scales Vertically and Horizontally

Auto-Sharding

Page 9: MongoDB API Talk @ HackPrinceton

*

Durable

•Automated replication and failover

•Multi-data center support

•Data remains consistent

Page 10: MongoDB API Talk @ HackPrinceton

*

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

Page 11: MongoDB API Talk @ HackPrinceton

*

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

Page 12: MongoDB API Talk @ HackPrinceton

*

Simple: How many people live in Princeton?

Page 13: MongoDB API Talk @ HackPrinceton

*

Simple: How many towns called Princeton in the US?

Page 14: MongoDB API Talk @ HackPrinceton

*

What are the 3 most populous “Princetons” in the US?

Page 15: MongoDB API Talk @ HackPrinceton

*

Geo: 3 most populous towns within 10 miles of Princeton

Page 16: MongoDB API Talk @ HackPrinceton

*

Geo: Nearest Towns to Princeton that Have “ville” in the name

Page 17: MongoDB API Talk @ HackPrinceton

*

Geo: Nearest Towns to Princeton that Have “ville” in the name

Page 18: MongoDB API Talk @ HackPrinceton

*

Text Search: Most Populous Cities with “Fall” in the name

Page 19: MongoDB API Talk @ HackPrinceton

*

Text Search and Geo Together

Page 20: MongoDB API Talk @ HackPrinceton

*

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

Page 21: MongoDB API Talk @ HackPrinceton

*

Example: Recreating Cities Data Set

•Cities data set actually transformed from zip codes

Page 22: MongoDB API Talk @ HackPrinceton

*

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

Page 23: MongoDB API Talk @ HackPrinceton

*

Example: Recreating Cities Data Set

Page 24: MongoDB API Talk @ HackPrinceton

*

Outputting Cities Data Set

Page 25: MongoDB API Talk @ HackPrinceton

Recommended