Building applications with MongoDB – An introduction

Slides:



Advertisements
Similar presentations
Introduction to MongoDB
Advertisements

Mongo An alternative database system. Installing Mongo We must install both the Mongo database and at least one GUI for managing Mongo See
Tornado Web and MongoDB An Introduction to AsyncMongo MongoBoston John C. Zablocki Development Manager, HealthcareSource Organizer, Beantown.
In 10 minutes Mohannad El Dafrawy Sara Rodriguez Lino Valdivia Jr.
An introduction to MongoDB Rácz Gábor ELTE IK, febr. 10.
Building applications with MongoDB – An introduction Roger
Jeff Lemmerman Matt Chimento Medtronic Confidential 1 9th Annual CodeFreeze Symposium Medtronic Energy and Component Center.
A Social blog using MongoDB ITEC-810 Final Presentation Lucero Soria Supervisor: Dr. Jian Yang.
Software Engineer, #MongoDBDays.
MONGODB NOSQL SERIES Karol Rástočný 1. Prominent Users 2  AppScale, bit.ly, Business Insider, CERN LHC, craigslist, diaspora, Disney Interactive Media.
MongoDB An introduction. What is MongoDB? The name Mongo is derived from Humongous To say that MongoDB can handle a humongous amount of data Document.
Is Apache CouchDB for you?
NoSQL continued CMSC 461 Michael Wilson. MongoDB  MongoDB is another NoSQL solution  Provides a bit more structure than a solution like Accumulo  Data.
WTT Workshop de Tendências Tecnológicas 2014
Goodbye rows and tables, hello documents and collections.
MongoDB Replica,Shard Cluster 中央大學電算中心 楊素秋
Methodological Foundations of Biomedical Informatics (BMSC-GA 4449) Himanshu Grover.
Open Search Office Web Services Database Doc Mgt Sys Pipeline Index Geospatial Analysis Text Search Faceting Caching Query parsing Clustering Synonyms.
WEEK 1, DAY 2 STEVE CHENOWETH CSSE DEPT CSSE 533 –INTRO TO MONGODB.
ArcGIS Server for Administrators
MapReduce and GFS. Introduction r To understand Google’s file system let us look at the sort of processing that needs to be done r We will look at MapReduce.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Architecture.
MongoDB is a database management system designed for web applications and internet infrastructure. The data model and persistence strategies are built.
Authors Brian F. Cooper, Raghu Ramakrishnan, Utkarsh Srivastava, Adam Silberstein, Philip Bohannon, Hans-Arno Jacobsen, Nick Puz, Daniel Weaver, Ramana.
MongoDB First Light. Mongo DB Basics Mongo is a document based NoSQL. –A document is just a JSON object. –A collection is just a (large) set of documents.
NoSQL Or Peles. What is NoSQL A collection of various technologies meant to work around RDBMS limitations (mostly performance) Not much of a definition...
Introduction to MongoDB. Database compared.
CMPE 226 Database Systems May 3 Class Meeting Department of Computer Engineering San Jose State University Spring 2016 Instructor: Ron Mak
CS422 Principles of Database Systems Introduction to NoSQL Chengyu Sun California State University, Los Angeles.
COMP 430 Intro. to Database Systems MongoDB. What is MongoDB? “Humongous” DB NoSQL, no schemas DB Lots of similarities with SQL RDBMs, but with more flexibility.
Why NO-SQL ?  Three interrelated megatrends  Big Data  Big Users  Cloud Computing are driving the adoption of NoSQL technology.
Data Management in the Cloud
Introduction to Mongo DB(NO SQL data Base)
Plan for Final Lecture What you may expect to be asked in the Exam?
CSE-291 (Distributed Systems) Winter 2017 Gregory Kesden
Mongo Database (Intermediate)
NO SQL for SQL DBA Dilip Nayak & Dan Hess.
and Big Data Storage Systems
Cloud Computing and Architecuture
Hadoop.
Special Topics in CCIT: Databases
MongoDB Er. Shiva K. Shrestha ME Computer, NCIT
WinCC OA NextGen Archiver: OSS Database selection process Dipl. -Ing
Open Source distributed document DB for an enterprise
MongoDB Distributed Write and Read
Learning MongoDB ZhangGang
Platform as a Service.
CMPE 280 Web UI Design and Development October 17 Class Meeting
Dineesha Suraweera.
MongoDB CRUD Operations
javascript for your data
Twitter & NoSQL Integration with MVC4 Web API
PHP / MySQL Introduction
NOSQL databases and Big Data Storage Systems
CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden
MongoDB for Developers
MongoDB for SQL Developers
MongoDB for the SQL DBA.
Introduction to PIG, HIVE, HBASE & ZOOKEEPER
MIT GSL 2018 week 3 | thursday Meteor and App Ideation.
Building an online tool for spatial joins using open source software
CMPE 280 Web UI Design and Development October 18 Class Meeting
CS5220 Advanced Topics in Web Programming Introduction to MongoDB
INTRODUCTION TO MONgodb
CMPE 280 Web UI Design and Development March 14 Class Meeting
NoSQL databases An introduction and comparison between Mongodb and Mysql document store.
Lecture 4: File-System Interface
Web Application Development Using PHP
Server & Tools Business
Presentation transcript:

Building applications with MongoDB – An introduction 1 doc can have multiple of locations and index on it. Building applications with MongoDB – An introduction Roger Bodamer roger@10gen.com @rogerb http://mongodb.org http://10gen.com

Today’s Talk Developing your first Web Application with MongoDB What is MongoDB, Platforms and availability Data Modeling, queries and geospatial queries Location bases App Example uses MongoDB Javascript shell

Why MongoDB Intrinsic support for agile development Super low latency access to your data Very little CPU overhead No Additional caching layer required Built in Replication and Horizontal Scaling support

MongoDB Document Oriented Database Data is stored in documents, not tables / relations MongoDB is Implemented in C++ for best performance Platforms 32/64 bit Windows Linux, Mac OS-X, FreeBSD, Solaris Language drivers for: Ruby / Ruby-on-Rails Java C# JavaScript C / C++ Erlang Python, Perl others..... and much more ! ..

Design Want to build an app where users can check in to a location Leave notes or comments about that location Iterative Approach: Decide requirements Design documents Rinse, repeat :-)

Requirements Locations Need to store locations (Offices, Restaurants etc) Want to be able to store name, address and tags Maybe User Generated Content, i.e. tips / small notes ? Want to be able to find other locations nearby Memory mapped files, BSON, indexes, multiple data types, binary files, etc @ main datasets: places and checkins use cases: given current loc find places nearby; add notes to locations Record checkins Generate stats about checkins

Requirements Locations Need to store locations (Offices, Restaurants etc) Want to be able to store name, address and tags Maybe User Generated Content, i.e. tips / small notes ? Want to be able to find other locations nearby Checkins User should be able to ‘check in’ to a location Want to be able to generate statistics Memory mapped files, BSON, indexes, multiple data types, binary files, etc @ main datasets: places and checkins use cases: given current loc find places nearby; add notes to locations Record checkins Generate stats about checkins

Terminology RDBMS Mongo Table, View Collection Row(s) JSON Document Index Join Embedded Document Partition Shard Partition Key Shard Key

Collections loc1, loc2, loc3 User1, User2 Locations Users Documents go into collections Todays app: users , places, checkins loc1, loc2, loc3 User1, User2 Locations Users

JSON Sample Doc { _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : "roger", date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)", text : ”MongoSF", tags : [ ”San Francisco", ”MongoDB" ] } Notes: - _id is unique, but can be anything you’d like

BSON JSON has powerful, but limited set of datatypes Mongo extends datypes with Date, Int types, Id, … MongoDB stores data in BSON BSON is a binary representation of JSON Optimized for performance and navigational abilities Also compression See bsonspec.org

Locations v1 location1= { name: "10gen East Coast”, address: ”134 5th Avenue 3rd Floor”, city: "New York”, zip: "10011” }

Places v1 location1= { name: "10gen East Coast”, address: ”134 5th Avenue 3rd Floor”, city: "New York”, zip: "10011” } db.locations.find({zip:”10011”}).limit(10)

Places v2 location1 = { name: "10gen East Coast”, address: "17 West 18th Street 8th Floor”, city: "New York”, zip: "10011”, tags: [“business”, “mongodb”] }

Places v2 location1 = { name: "10gen East Coast”, address: "17 West 18th Street 8th Floor”, city: "New York”, zip: "10011”, tags: [“business”, “mongodb”] } db.locations.find({zip:”10011”, tags:”business”})

Places v3 location1 = { name: "10gen East Coast”, address: "17 West 18th Street 8th Floor”, city: "New York”, zip: "10011”, tags: [“business”, “mongodb”], latlong: [40.0,72.0] } Latlong are actually real lat / long points $near gives you the closest 100

Places v3 location1 = { db.locations.ensureIndex({latlong:”2d”}) name: "10gen East Coast”, address: "17 West 18th Street 8th Floor”, city: "New York”, zip: "10011”, tags: [“business”, “cool place”], latlong: [40.0,72.0] } db.locations.ensureIndex({latlong:”2d”}) Latlong are actually real lat / long points $near gives you the closest 100

Places v3 location1 = { db.locations.ensureIndex({latlong:”2d”}) name: "10gen HQ”, address: "17 West 18th Street 8th Floor”, city: "New York”, zip: "10011”, tags: [“business”, “cool place”], latlong: [40.0,72.0] } db.locations.ensureIndex({latlong:”2d”}) db.locations.find({latlong:{$near:[40,70]}}) Latlong are actually real lat / long points $near gives you the closest 100

Places v4 location1 = { name: "10gen HQ”, address: "17 West 18th Street 8th Floor”, city: "New York”, zip: "10011”, latlong: [40.0,72.0], tags: [“business”, “cool place”], tips: [ {user:"nosh", time:6/26/2010, tip:"stop by for office hours on Wednesdays from 4-6pm"}, {.....}, ] }

Querying your Places Creating your indexes db.locations.ensureIndex({tags:1}) db.locations.ensureIndex({name:1}) db.locations.ensureIndex({latlong:”2d”}) Finding places: db.locations.find({latlong:{$near:[40,70]}}) With regular expressions: db.locations.find({name: /^typeaheadstring/) By tag: db.locations.find({tags: “business”})

Inserting and updating locations Initial data load: db.locations.insert(place1) Using update to Add tips: db.locations.update({name:"10gen HQ"}, {$push :{tips: {user:"nosh", time:6/26/2010, tip:"stop by for office hours on Wednesdays from 4-6"}}}}

Requirements Locations Need to store locations (Offices, Restaurants etc) Want to be able to store name, address and tags Maybe User Generated Content, i.e. tips / small notes ? Want to be able to find other locations nearby Checkins User should be able to ‘check in’ to a location Want to be able to generate statistics Memory mapped files, BSON, indexes, multiple data types, binary files, etc @ main datasets: places and checkins use cases: given current loc find places nearby; add notes to locations Record checkins Generate stats about checkins

Users user1 = { name: “nosh” email: “nosh@10gen.com”, . checkins: [{ location: “10gen HQ”, ts: 9/20/2010 10:12:00, …}, … ] }

Simple Stats db.users.find({‘checkins.location’: “10gen HQ”) db.checkins.find({‘checkins.location’: “10gen HQ”}) .sort({ts:-1}).limit(10) db.checkins.find({‘checkins.location’: “10gen HQ”, ts: {$gt: midnight}}).count()

Alternative user1 = { name: “nosh” email: “nosh@10gen.com”, . checkins: [4b97e62bf1d8c7152c9ccb74, 5a20e62bf1d8c736ab] } checkins [] = ObjectId reference to locations collection

User Check in Check-in = 2 ops read location to obtain location id Update ($push) location id to user object Queries: find all locations where a user checked in: checkin_array = db.users.find({..}, {checkins:true}).checkins db.location.find({_id:{$in: checkin_array}})

Unsharded Deployment Configure as a replica set for automated failover Async replication between nodes Add more secondaries to scale reads Primary Secondary Secondary

Sharded Deployment MongoS config Primary Secondary Autosharding distributes data among two or more replica sets Mongo Config Server(s) handles distribution & balancing Transparent to applications

Use Cases RDBMS replacement for high-traffic web applications Content Management-type applications Real-time analytics High-speed data logging Web 2.0, Media, SaaS, Gaming, Finance, Telecom, Healthcare

10Gen is hiring! @mongodb roger@10gen.com @rogerb http://mongodb.org http://10gen.com