• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduction to MongoDB
 

Introduction to MongoDB

on

  • 4,473 views

Talk on MongoDB at local Ruby meetup

Talk on MongoDB at local Ruby meetup

Statistics

Views

Total Views
4,473
Views on SlideShare
3,975
Embed Views
498

Actions

Likes
10
Downloads
88
Comments
0

8 Embeds 498

http://blog.platform45.com 448
http://www.slideshare.net 25
http://coderwall.com 9
http://ec2-79-125-83-211.eu-west-1.compute.amazonaws.com 7
https://wiki.bouvet.no 5
http://www.eeca.catalystdemo.net.nz 2
http://webcache.googleusercontent.com 1
http://web.archive.org 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • Old man - SQL <br /> DoD - MongoDB <br />
  • Old man - SQL <br /> DoD - MongoDB <br />
  • Old man - SQL <br /> DoD - MongoDB <br />
  • Document Orientated: It isnt stored as records and tables, information stored as documents or objects <br /> Build for speed: No transaction log / removed anything that would slow it down <br /> Rich document based queries: Users can find documents based on any search criteria / similar to SQL <br /> Full index support: Index on any attribute - similar to SQL <br /> Replication and failover: Supports replication of data between servers for failover and redundancy <br /> Auto sharding: Scale horizontally without compromising functionality - EVERY EASY - NO JOINS <br /> Map Reduce - Database itself can perform advanced aggregation and data processing <br />
  • <br />
  • Websites: Object orientated programming languages - Easy persistence of objects <br /> Caching: Extremely fast <br /> High scalability: Easy Auto sharding and replication and failover <br /> <br />
  • * SQL writes to transaction log (for data durability) <br /> * Performance loss <br /> * MongoDB doesn&#x2019;t do this - Uses replication <br />
  • Similarities and Differences between SQL and document orientated databases <br />
  • No need for any rake db:creates or rake db:setup <br />
  • No need for any rake db:creates or rake db:setup <br />
  • Like a table in MySQL <br /> EXCEPT!!! <br /> Capped collections: Extremely fast, atomic writes, good for log files <br />
  • Like a table in MySQL <br /> EXCEPT!!! <br /> Capped collections: Extremely fast, atomic writes, good for log files <br />
  • <br />
  • <br />
  • <br />
  • Next up is relations - which is one of the major differences or advantages over SQL <br />
  • First class - objects that can stand alone (users -> blog posts) <br />
  • Similar to MySQL <br /> Tags: Array of ID&#x2019;s Many to many <br /> Comments: belongs_to / has_many <br />
  • <br />
  • <br />
  • Using mongodb with ruby <br />
  • First up: <br /> <br /> Mongomapper <br /> by jnunemaker <br /> Works for OrderedList <br /> <br /> Typecasting: Mongodb doesnt understand types - MongoMapper creates the typecasting <br />
  • Durran - Hashrocket <br />
  • <br />
  • <br />
  • <br />
  • <br />

Introduction to MongoDB Introduction to MongoDB Presentation Transcript

  • Getting started with MongoDB
  • Introduction
  • Introduction Relational Database
  • Introduction Document Relational Orientated Database Database
  • Introduction Document Relational Orientated Database Database NoSQL Bra.
  • What is MongoDB? • Scalable high-performance open source, document- orientated database • Built for speed • Rich document based queries • Full index support • Replication and Failover • Auto Sharding • Map / Reduce
  • Why use MongoDB? • SQL was invented in the 70’s to store data • MongoDB stores documents / objects • We work with objects (Ruby) • We need databases to persist our objects • So why not just store objects directly?
  • What its great for • Websites • Caching • High scalability • Storage of program objects and JSON
  • What its not great for • Highly transactional applications • Problems requiring SQL
  • Differences
  • When I Say Database
  • When I Say Think Database Database
  • When I Say Think Database Database • Made up of multiple collections • Are created on-the-fly when first referenced
  • When I Say Collection
  • When I Say Think Collection Table
  • When I Say Think Collection Table • Schema-less • Indexable by one or more keys • Created on-the-fly when first referenced • Capped collections: Fixed size, older records dropped after limit reached
  • When I Say Document
  • When I Say Think Document Record / Row
  • When I Say Think Document Record / Row • Stored in a collection • Can have _id key - Works like primary keys in MySQL • Supports relationships: embedded or referential • Document storage in BSON
  • When I Say Think Document Record / Row • Stored in a collection • Can have _id key - Works like primary keys in MySQL • Supports relationships: embedded or referential • Document storage in BSON JSONS Binary Brother
  • Relations
  • Referential / Normalised • Same as SQL • “First class” objects that are at top level • Many to many relationships has_many User Blog Post belongs_to
  • # Post { title: “Getting started with MongoDB”, body: “blah blah blah ... “, created: Date(’09-06-2010’), tags: [1, 2] } # Comments # Tags { { id: 1, body: “I did not have relations..”, name: “example” user_id: 1, }, { post_id: 1, id: 2, created: Date(’09-06-2010’), name: “lol” } }
  • Embedded • Embedded is pre-joining • Embed when document always appears with parent • 4MB document size limit Blog Post Post Title Post Body Comments
  • # Posts { title: “Getting started with MongoDB”, body: “blah blah blah ... “, created: Date(’09-06-2010’), Array tags: [ ‘example’, ‘bill clinton’ ], comments: [ { author: “Bill”, comment: “I did not have relations” }, { author: “Monica”, comment: “LOL” } ] } Array of hashes
  • Ruby MongoDB
  • MongoMapper http://github.com/jnunemaker/mongomapper • Typecasting • Callbacks (ActiveSupport Callbacks) • Validations • Connection and database can differ per document • Has create, update methods • Find: id, ids, :all, :first, :last • Associations (has_one, has_many, many_to_many)
  • http://www.mongoid.org • Named scopes / chainable criteria • Versioning of your documents • Full callback support on documents AND embedded documents • Proper master/slave distribution • Optimised for use with extremely large datasets This is what we use!
  • Demo
  • Conclusions • NoSQL is pretty scary / We’re used to SQL • It’s the future.
  • Chat to us online: twitter: @platform45
  • Discussion