SlideShare a Scribd company logo
Solutions Architect, MongoDB
Heather Kirksey
#MongoDB
User Data Management
with MongoDB
Agenda
Agenda
• High Level Overview
– MongoDB
– User Data
• Modeling & Querying User Data
– Insurance Company User Data
– User Check-Ins
• Extending the Data Model for Future Use Cases
– Tracking UserActivity
– Social Media
MongoDB is a(n) ___________
database
• Document
• Open source
• High performance
• Horizontally scalable
• Full featured
User Data
• Account Information
– Name, address, etc.
– Account status
– Notes
• Activity Streams
– Posts, tweets, likes, check-ins
– Recording user actions
• Social Networks
– Friends, connections
– Groups, tags
Data Modeling Exercise
• Insurance Company Data
• Account information
– Name, address, etc
– Account status
– Notes
Data Modeling Example
Data Modeling Example
User Opened
Date: 05/26/2013
Status: Successful
Account Modified
Date: 06/04/2013
Status: Added spouse
User Call Log
Date: 01/22/2014
Type: Complaint
Insurance Company Site
User Opened
Date: 05/26/2013
Status: Successful
Account Modified
Date: 06/04/2013
Status: Added spouse
User Call Log
Date: 01/22/2014
Type: Complaint
2 types
of data
2 types
of data
Rule of Thumb
• Categories of data map well to MongoDB
Collections
Policies Activities
Policies
policy = {
name: “John Smith”
employer: “10gen”,
address: “555 Fictional
Ave”,
e-mail:
“me@john.smith.com”,
spouse: “Yes” ,
dependents: “No”,
dates: [
{start: 5/26/2013
10:12:00},
end: 5/26/2023
10:12:00}],
Activities
activity = {
user-id: “JohnSmith421”
type: “account-opening”
,
status: “Success”,
dates: 5/26/2013
10:12:00,
related-doc:
“/customer/JohnSmith421/open
.pdf”
}
User Opened Account
Date: 05/26/2013
Status: Success
Account Modified
Date: 06/04/2013
Action: Added Spouse
User Call Log
Date: 01/22/2014
Type: Complaint
User Check-Ins
• Activity Streams
– Posts, tweets, check-ins
– Recording user actions
Places
Q: Current location
A: Places near location
User Generated
Content
Places
Inserting a Place
var p = { name: “MongoDB HQ”,
address:“229 W 43rd St”,
city: “NewYork”,
zip: “10036”,
tags: [“mongoDB”,“business”],
latlong: [40.0, 72.0],
tips: [{user:“John Smith”, time: “3/15/2013”,tip:“Make sure to stop by
for office hours!”}]}
> db.posts.save(p)
Updating Tips
db.places.update({name: “MongoDB HQ”},
{$push :{tips:
{user: “John”, time:3/10/2014,
tip: “stop by for office hours on
Wednesdays from 4-6”}}})
Querying Our Places
• Creating Indexes
• db.places.ensureIndex({tags:1})
• db.places.ensureIndex({name:1})
• db.places.ensureIndex({latlong:”2d”})
• Finding Places
• db.places.find({latlong:{$near:[40,70]}})
• Regular Expressions
• db.places.find({name: /^typeaheadstring/)
• Using Tags
• db.places.find({tags: “business”})
User Check Ins
Record User Check-Ins
Check-Ins
Users
Stats
Users
Stats
Users
user1 = {
name: “John Smith”
e-mail: “me@john.smith.com”,
check-ins: [4b97e62bf1d8c7152c9ccb74,
5a20e62bf1d8c736ab]
}
checkins [] = ObjectId reference to Check-Ins
Collection
Check-Ins
user1 = {
place: “MongoDB HQ”,
ts: 9/20/2010 10:12:00,
userId: <object id of user>
}
Every Check-In is Two Operations
• Insert a Check-In Object (check-ins collection)
• Update ($push) user object with check-in ID (users
collection)
Simple Stats
db.checkins.find({place: “MongoDB HQ”)
db.checkins.find({place: “MongoDB HQ”})
.sort({ts:-1}).limit(10)
db.checkins.find({place: “MongoDB HQ”,
ts: {$gt: midnight}}).count()
Stats w/ MapReduce
mapFunc = function() {emit(this.place, 1);}
reduceFunc = function(key, values) {return
Array.sum(values);}
res = db.checkins.mapReduce(mapFunc,reduceFunc,
{query: {timestamp: {$gt:nowminus3hrs}}})
res = [{_id:”MongoDB HQ”, value: 17}, … , …]
…or try using the aggregation framework!
Adding More User Data
User Opened
Date: 05/26/2013
Status: Successful
Account Modified
Date: 06/04/2013
Status: Added spouse
User Call Log
Date: 01/22/2014
Type: Complaint
Tracking Clicks
Policies Activities
Each Click Creates a New Doc
Policies Activities Clicks
Clicks
click = {
user: “JohnSmith”,
ts: 9/20/2010 10:12:00,
link: “http://some-link-here.com/wherever”
}
Now we can audit user activity...
db.clicks.find({user:”JohnSmith”}).sort({ts:-1})
Show me all of John’s clicks sorted by timestamp.
Extending the Schema
user1 = {
name: “John Smith”
e-mail: “me@John.Smith.com”,
check-ins:
[4b97e62bf1d8c7152c9ccb74,
5a20e62bf1d8c736ab]
}
Extending the Schema
user1 = {
name: “John Smith”
e-mail: “me@John.Smith.com”,
check-ins:
[4b97e62bf1d8c7152c9ccb74, 5a20e62bf1d
8c736ab]
}
friends:
[7b47j62bk1d3c5621c1icv90, 1h11p62bf1d8
c716za]
Takeaways
• User data fits well in MongoDB
– Flexible data model
– Stay agile; make changes
– Many customers in production
• Application patterns drive data design
– Optimize data model for queries
– Primary use cases drive design
• Adding features is easy
– Create new data structures
– Extend existing
Questions?
MongoDB World
New York City, June 23-25
#MongoDBWorld
See what’s next in MongoDB including
• MongoDB 2.6
• Sharding
• Replication
• Aggregation
http://world.mongodb.com
Save $200 with discount code THANKYOU
Solutions Architect, MongoDB
Heather Kirksey
#MongoDB
Thank You

More Related Content

What's hot (20)

PDF
Learn Learn how to build your mobile back-end with MongoDB
Marakana Inc.
 
PDF
Webinar: Building Your First App with MongoDB and Java
MongoDB
 
PPT
5 Pitfalls to Avoid with MongoDB
Tim Callaghan
 
PDF
MongoDB Schema Design
Alex Litvinok
 
PPTX
Back to Basics 1: Thinking in documents
MongoDB
 
PDF
Building your first app with mongo db
MongoDB
 
PPTX
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
MongoDB
 
PDF
MongoDB and Schema Design
Matias Cascallares
 
PPTX
MongoDB for Developers
Ciro Donato Caiazzo
 
KEY
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
PDF
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB
 
PPTX
Webinar: Best Practices for Getting Started with MongoDB
MongoDB
 
PPTX
Indexing Strategies to Help You Scale
MongoDB
 
PPTX
Dev Jumpstart: Schema Design Best Practices
MongoDB
 
PDF
Building your first app with MongoDB
Norberto Leite
 
PPTX
Database Trends for Modern Applications: Why the Database You Choose Matters
MongoDB
 
PPTX
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
PPTX
Back to Basics: My First MongoDB Application
MongoDB
 
PPTX
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
MongoDB
 
PDF
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB
 
Learn Learn how to build your mobile back-end with MongoDB
Marakana Inc.
 
Webinar: Building Your First App with MongoDB and Java
MongoDB
 
5 Pitfalls to Avoid with MongoDB
Tim Callaghan
 
MongoDB Schema Design
Alex Litvinok
 
Back to Basics 1: Thinking in documents
MongoDB
 
Building your first app with mongo db
MongoDB
 
Conceptos básicos. seminario web 3 : Diseño de esquema pensado para documentos
MongoDB
 
MongoDB and Schema Design
Matias Cascallares
 
MongoDB for Developers
Ciro Donato Caiazzo
 
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB
 
Webinar: Best Practices for Getting Started with MongoDB
MongoDB
 
Indexing Strategies to Help You Scale
MongoDB
 
Dev Jumpstart: Schema Design Best Practices
MongoDB
 
Building your first app with MongoDB
Norberto Leite
 
Database Trends for Modern Applications: Why the Database You Choose Matters
MongoDB
 
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
Back to Basics: My First MongoDB Application
MongoDB
 
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
MongoDB
 
MongoDB .local Chicago 2019: Practical Data Modeling for MongoDB: Tutorial
MongoDB
 

Similar to User Data Management with MongoDB (20)

PDF
Webinar: User Data Management with MongoDB
MongoDB
 
KEY
Building Your First MongoDB Application
Rick Copeland
 
PDF
Webinar: User Data Management with MongoDB
MongoDB
 
PPTX
Webinar: Building Your First Application with MongoDB
MongoDB
 
PDF
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
MongoDB
 
KEY
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
Daniel Cousineau
 
PDF
MongoDB FabLab León
Juan Antonio Roy Couto
 
PPT
Building web applications with mongo db presentation
Murat Çakal
 
PPTX
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
PDF
MongoDB Atlas Workshop - Singapore
Ashnikbiz
 
PPTX
Introduction to MongoDB
MongoDB
 
PPTX
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB
 
PPTX
Past, Present and Future of Data Processing in Apache Hadoop
Codemotion
 
KEY
MongoDB
Steven Francia
 
PPTX
Beyond the Basics 2: Aggregation Framework
MongoDB
 
PPTX
Data Analytics with MongoDB - Jane Fine
MongoDB
 
PDF
From SQL to MongoDB
Nuxeo
 
PPTX
How to leverage MongoDB for Big Data Analysis and Operations with MongoDB's A...
Gianfranco Palumbo
 
PPTX
Introduction to MongoDB at IGDTUW
Ankur Raina
 
Webinar: User Data Management with MongoDB
MongoDB
 
Building Your First MongoDB Application
Rick Copeland
 
Webinar: User Data Management with MongoDB
MongoDB
 
Webinar: Building Your First Application with MongoDB
MongoDB
 
MongoDB.local DC 2018: Tutorial - Data Analytics with MongoDB
MongoDB
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
Daniel Cousineau
 
MongoDB FabLab León
Juan Antonio Roy Couto
 
Building web applications with mongo db presentation
Murat Çakal
 
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
MongoDB Atlas Workshop - Singapore
Ashnikbiz
 
Introduction to MongoDB
MongoDB
 
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB
 
Past, Present and Future of Data Processing in Apache Hadoop
Codemotion
 
Beyond the Basics 2: Aggregation Framework
MongoDB
 
Data Analytics with MongoDB - Jane Fine
MongoDB
 
From SQL to MongoDB
Nuxeo
 
How to leverage MongoDB for Big Data Analysis and Operations with MongoDB's A...
Gianfranco Palumbo
 
Introduction to MongoDB at IGDTUW
Ankur Raina
 
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
Ad

Recently uploaded (20)

PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Digital Circuits, important subject in CS
contactparinay1
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 

User Data Management with MongoDB

  • 1. Solutions Architect, MongoDB Heather Kirksey #MongoDB User Data Management with MongoDB
  • 3. Agenda • High Level Overview – MongoDB – User Data • Modeling & Querying User Data – Insurance Company User Data – User Check-Ins • Extending the Data Model for Future Use Cases – Tracking UserActivity – Social Media
  • 4. MongoDB is a(n) ___________ database • Document • Open source • High performance • Horizontally scalable • Full featured
  • 5. User Data • Account Information – Name, address, etc. – Account status – Notes • Activity Streams – Posts, tweets, likes, check-ins – Recording user actions • Social Networks – Friends, connections – Groups, tags
  • 6. Data Modeling Exercise • Insurance Company Data • Account information – Name, address, etc – Account status – Notes
  • 8. Data Modeling Example User Opened Date: 05/26/2013 Status: Successful Account Modified Date: 06/04/2013 Status: Added spouse User Call Log Date: 01/22/2014 Type: Complaint
  • 9. Insurance Company Site User Opened Date: 05/26/2013 Status: Successful Account Modified Date: 06/04/2013 Status: Added spouse User Call Log Date: 01/22/2014 Type: Complaint 2 types of data 2 types of data
  • 10. Rule of Thumb • Categories of data map well to MongoDB Collections Policies Activities
  • 11. Policies policy = { name: “John Smith” employer: “10gen”, address: “555 Fictional Ave”, e-mail: “[email protected]”, spouse: “Yes” , dependents: “No”, dates: [ {start: 5/26/2013 10:12:00}, end: 5/26/2023 10:12:00}],
  • 12. Activities activity = { user-id: “JohnSmith421” type: “account-opening” , status: “Success”, dates: 5/26/2013 10:12:00, related-doc: “/customer/JohnSmith421/open .pdf” } User Opened Account Date: 05/26/2013 Status: Success Account Modified Date: 06/04/2013 Action: Added Spouse User Call Log Date: 01/22/2014 Type: Complaint
  • 13. User Check-Ins • Activity Streams – Posts, tweets, check-ins – Recording user actions
  • 14. Places Q: Current location A: Places near location User Generated Content Places
  • 15. Inserting a Place var p = { name: “MongoDB HQ”, address:“229 W 43rd St”, city: “NewYork”, zip: “10036”, tags: [“mongoDB”,“business”], latlong: [40.0, 72.0], tips: [{user:“John Smith”, time: “3/15/2013”,tip:“Make sure to stop by for office hours!”}]} > db.posts.save(p)
  • 16. Updating Tips db.places.update({name: “MongoDB HQ”}, {$push :{tips: {user: “John”, time:3/10/2014, tip: “stop by for office hours on Wednesdays from 4-6”}}})
  • 17. Querying Our Places • Creating Indexes • db.places.ensureIndex({tags:1}) • db.places.ensureIndex({name:1}) • db.places.ensureIndex({latlong:”2d”}) • Finding Places • db.places.find({latlong:{$near:[40,70]}}) • Regular Expressions • db.places.find({name: /^typeaheadstring/) • Using Tags • db.places.find({tags: “business”})
  • 18. User Check Ins Record User Check-Ins Check-Ins Users Stats Users Stats
  • 19. Users user1 = { name: “John Smith” e-mail: “[email protected]”, check-ins: [4b97e62bf1d8c7152c9ccb74, 5a20e62bf1d8c736ab] } checkins [] = ObjectId reference to Check-Ins Collection
  • 20. Check-Ins user1 = { place: “MongoDB HQ”, ts: 9/20/2010 10:12:00, userId: <object id of user> } Every Check-In is Two Operations • Insert a Check-In Object (check-ins collection) • Update ($push) user object with check-in ID (users collection)
  • 21. Simple Stats db.checkins.find({place: “MongoDB HQ”) db.checkins.find({place: “MongoDB HQ”}) .sort({ts:-1}).limit(10) db.checkins.find({place: “MongoDB HQ”, ts: {$gt: midnight}}).count()
  • 22. Stats w/ MapReduce mapFunc = function() {emit(this.place, 1);} reduceFunc = function(key, values) {return Array.sum(values);} res = db.checkins.mapReduce(mapFunc,reduceFunc, {query: {timestamp: {$gt:nowminus3hrs}}}) res = [{_id:”MongoDB HQ”, value: 17}, … , …] …or try using the aggregation framework!
  • 23. Adding More User Data User Opened Date: 05/26/2013 Status: Successful Account Modified Date: 06/04/2013 Status: Added spouse User Call Log Date: 01/22/2014 Type: Complaint
  • 25. Each Click Creates a New Doc Policies Activities Clicks
  • 26. Clicks click = { user: “JohnSmith”, ts: 9/20/2010 10:12:00, link: “http://some-link-here.com/wherever” } Now we can audit user activity... db.clicks.find({user:”JohnSmith”}).sort({ts:-1}) Show me all of John’s clicks sorted by timestamp.
  • 27. Extending the Schema user1 = { name: “John Smith” e-mail: “[email protected]”, check-ins: [4b97e62bf1d8c7152c9ccb74, 5a20e62bf1d8c736ab] }
  • 28. Extending the Schema user1 = { name: “John Smith” e-mail: “[email protected]”, check-ins: [4b97e62bf1d8c7152c9ccb74, 5a20e62bf1d 8c736ab] } friends: [7b47j62bk1d3c5621c1icv90, 1h11p62bf1d8 c716za]
  • 29. Takeaways • User data fits well in MongoDB – Flexible data model – Stay agile; make changes – Many customers in production • Application patterns drive data design – Optimize data model for queries – Primary use cases drive design • Adding features is easy – Create new data structures – Extend existing
  • 31. MongoDB World New York City, June 23-25 #MongoDBWorld See what’s next in MongoDB including • MongoDB 2.6 • Sharding • Replication • Aggregation http://world.mongodb.com Save $200 with discount code THANKYOU
  • 32. Solutions Architect, MongoDB Heather Kirksey #MongoDB Thank You