Please ask questions! Have people used non-relational dbs before? MongoDB?



Similar documents
MongoDB. Or how I learned to stop worrying and love the database. Mathias Stearn. N*SQL Berlin October 22th, gen

L7_L10. MongoDB. Big Data and Analytics by Seema Acharya and Subhashini Chellappan Copyright 2015, WILEY INDIA PVT. LTD.

Getting Started with MongoDB

Scaling up = getting a better machine. Scaling out = use another server and add it to your cluster.

Introduction to MongoDB. Kristina Chodorow

Building Your First MongoDB Application

MongoDB. The Definitive Guide to. The NoSQL Database for Cloud and Desktop Computing. Apress8. Eelco Plugge, Peter Membrey and Tim Hawkins

MongoDB Developer and Administrator Certification Course Agenda

NOSQL INTRODUCTION WITH MONGODB AND RUBY GEOFF

Overview of Databases On MacOS. Karl Kuehn Automation Engineer RethinkDB

Big Data & Data Science Course Example using MapReduce. Presented by Juan C. Vega

The MongoDB Tutorial Introduction for MySQL Users. Stephane Combaudon April 1st, 2014

MongoDB Aggregation and Data Processing

MongoDB: document-oriented database

MongoDB Aggregation and Data Processing Release 3.0.4

MongoDB Aggregation and Data Processing

Dr. Chuck Cartledge. 15 Oct. 2015

Introduction to NoSQL and MongoDB. Kathleen Durant Lesson 20 CS 3200 Northeastern University

SURVEY ON MONGODB: AN OPEN- SOURCE DOCUMENT DATABASE

.NET User Group Bern

Brad Dayley. NoSQL with MongoDB

Document Oriented Database

NoSQL, But Even Less Security Bryan Sullivan, Senior Security Researcher, Adobe Secure Software Engineering Team

Certified MongoDB Professional VS-1058

Data Model Design for MongoDB

Can the Elephants Handle the NoSQL Onslaught?

NoSQL - What we ve learned with mongodb. Paul Pedersen, Deputy CTO paul@10gen.com DAMA SF December 15, 2011

MongoDB and Couchbase

Cloudant Querying Options

Spring Data, Jongo & Co. Java Persistenz-Frameworks für MongoDB

Building a RESTful service with MongoDB and Spring MVC

these three NoSQL databases because I wanted to see a the two different sides of the CAP

Scaling with MongoDB. by Michael Schurter Scaling with MongoDB by Michael Schurter - OS Bridge,

MongoDB in the NoSQL and SQL world. Horst Rechner Berlin,

MONGODB - THE NOSQL DATABASE

NoSQL in der Cloud Why? Andreas Hartmann

Cloud Scale Distributed Data Storage. Jürmo Mehine

NoSQL web apps. w/ MongoDB, Node.js, AngularJS. Dr. Gerd Jungbluth, NoSQL UG Cologne,

Attacking MongoDB. Firstov Mihail

Transactions and ACID in MongoDB

Open source, high performance database

NoSQL Databases, part II

Integrating Big Data into the Computing Curricula

Frictionless Persistence in.net with MongoDB. Mogens Heller Grabe Trifork

MongoDB. An introduction and performance analysis. Seminar Thesis

Python and MongoDB. Why?

An Open Source NoSQL solution for Internet Access Logs Analysis

Perl & NoSQL Focus on MongoDB. Jean-Marie Gouarné jmgdoc@cpan.org

NoSQL Database - mongodb

NoSQL replacement for SQLite (for Beatstream) Antti-Jussi Kovalainen Seminar OHJ-1860: NoSQL databases

MongoDB: The Definitive Guide

Visual Statement. NoSQL Data Storage. MongoDB Project. April 10, Bobby Esfandiari Stefan Schielke Nicole Saat

Advanced Data Management Technologies

Tobby Hagler, Phase2 Technology

PHP and MongoDB Web Development Beginners Guide by Rubayeet Islam

Application of NoSQL Database in Web Crawling

Big data and urban mobility

NoSQL: Going Beyond Structured Data and RDBMS

Introduction to Hadoop. New York Oracle User Group Vikas Sawhney

Programming Against Hybrid Databases with Java Handling SQL and NoSQL. Brian Hughes IBM

Why NoSQL? Your database options in the new non- relational world IBM Cloudant 1

CSCC09F Programming on the Web. Mongo DB

ADVANCED DATABASES PROJECT. Juan Manuel Benítez V Gledys Sulbaran

DbSchema Tutorial with Introduction in MongoDB

NoSQL Databases. Nikos Parlavantzas

Replicating to everything

Not Relational Models For The Management of Large Amount of Astronomical Data. Bruno Martino (IASI/CNR), Memmo Federici (IAPS/INAF)

Tutorial: Big Data Algorithms and Applications Under Hadoop KUNPENG ZHANG SIDDHARTHA BHATTACHARYYA

Analytics March 2015 White paper. Why NoSQL? Your database options in the new non-relational world

A COMPARATIVE STUDY OF NOSQL DATA STORAGE MODELS FOR BIG DATA

Virtual file system on NoSQL for processing high volumes of HL7 messages

Big Data. Facebook Wall Data using Graph API. Presented by: Prashant Patel Jaykrushna Patel

The evolution of database technology (II) Huibert Aalbers Senior Certified Executive IT Architect

Big Data Solutions. Portal Development with MongoDB and Liferay. Solutions

In Memory Accelerator for MongoDB

nosql and Non Relational Databases

Sharding and MongoDB. Release MongoDB, Inc.

Benchmarking Couchbase Server for Interactive Applications. By Alexey Diomin and Kirill Grigorchuk

Sharding and MongoDB. Release MongoDB, Inc.

Hacettepe University Department Of Computer Engineering BBM 471 Database Management Systems Experiment

Cloud Powered Mobile Apps with Azure

How, What, and Where of Data Warehouses for MySQL

3 Case Studies of NoSQL and Java Apps in the Real World

NoSQL Database Systems and their Security Challenges

NoSQL Databases. Institute of Computer Science Databases and Information Systems (DBIS) DB 2, WS 2014/2015

Visualizing MongoDB Objects in Concept and Practice

NORWEGIAN UNIVERSITY OF SCIENCE AND TECHNOLOGY DEPARTMENT OF CHEMICAL ENGINEERING ADVANCED PROCESS SIMULATION. SQL vs. NoSQL

Comparisons Between MongoDB and MS-SQL Databases on the TWC Website

Evaluation of NoSQL databases for large-scale decentralized microblogging

Why MySQL beats MongoDB

Big data is like teenage sex: everyone talks about it, nobody really knows how to do it, everyone thinks everyone else is doing it, so everyone

Transcription:

Kristina Chodorow

Please ask questions! Have people used non-relational dbs before? MongoDB?

Software Engineer at $ whoami

Scaling a Pre-WWW DB

literally scale

literally scale (Courtesy of Ask Bjorn Hansen) $3,200 x 1250 = $4,000,000

shard now-yesterday yesterdaythe day before the day beforethe day before that

master-slave replication R R/W? W W W R

CAP Theorem: Choose Two Consistency name : "joe" name : "joe" Availability Partitioning

Consistency Availability Partitioning

Consistency Availability Partitioning master slave

Consistency Availability Partitioning slave

Consistency Availability Partitioning master

Consistency Availability Partitioning slave master

Consistency Availability Partitioning Pair Router Pair Pair...eventual consistency

Mongo Philosophy Go horizontal You can always lose a machine Safety in numbers

Using MongoDB & PHP

More Mongo Philosophy Everyone knows some JavaScript Performance!

www.mongodb.org Comes with binaries for MongoDB server, shell, and import/export tools

The PHP Driver $ pecl install mongo Add to php.ini: extension=mongo.so

Other Drivers C#, Erlang, Factor

Connecting to the Database $connection = new Mongo(); $db = $connection->selectdb('test'); $collection = $db->selectcollection('foo');

Collections, not Tables

array( 'date' => new MongoDate, 'time' => array( 'start' => 9.25, 'end' => 10.25 ), 'sum' => 0, 'comments' => array( "task 1", "run 4" ) ) Collections

Inserting $c->insert(array('name' => "Joe", 'age' : 34)) var_dump($c->findone(array('name' => "Joe"))); array(3) { ["_id"]=> object(mongoid)#6 (0) { } ["name"]=> string(3) "Joe", ["age"]=> int(34) }

Inserting Objects class Post { public $comments = array(); public function construct($author, $title, $content) { $this->author = $author; $this->title = $title; $this->content = $content; } } $c->insert(new Post("Fred", "My first blog post", "Hello, World!"));

MongoId an autogenerated primary key $x = array("foo" => 1, "bar" => 2); $collection->insert($x); echo $x['_id']; Result: 2fe3e4d892aa73234c910bed

Autogenerated Primary Keys MongoId: "2fe3e4d892aa73234c910bed" 12 bytes: 2fe3e4d892aa73234c910bed ------ ---- -- ---- ts mac pid inc

Updating $collection->update(array("_id" => $id), array('$push' => array('comments' => array( 'author' => 'Fred', 'comment' => 'Dumb post.' ) )));

which gives us: echo json_encode($collection->findone()); -------------------------------------------- { _id : {}, "title" : "My first blog post", "author" : "Joe", "content" : "Hello, world!" "comments" : [{ "author" : "Fred", "comment" : "Dumb post" }] }

$ instead of >, <, =, etc. $gt, $gte, $lt, $lte, $eq, $neq, $exists, $set, $mod, $where, $in, $nin, $inc $push, $pull, $pop, $pushall, $popall $c->find(array("x" => array('$gt' => 4)))

$where $blog->findone(array('$where' => 'this.y == (this.x + this.z)')); Will work: array("x" => 1, "y" => 4, "z" => 3) array("x" => "hi", "y" => "hibye", "z" => "bye") Won t work: array("x" => 1, "y" => 1)

Optimizing $where db.blogs.findone({ name : "Sally", age : {'$gt' : 18}, $where : 'Array.sort(this.interests)[2] == "volleyball"'});

php.ini mongo.cmd = ":" $c->find(array("x" => array(':gt' => 4))); mongo.cmd = "=" $c->find(array("x" => array('=gt' => 4))); mongo.cmd = "#" $c->find(array("x" => array('#gt' => 4)));

ini_set ini_set("mongo.cmd", "."); $c->find(array("x" => array('.gt' => 4))); ini_set("mongo.cmd", "x"); $c->find(array("x" => array('xgt' => 4))); ini_set("mongo.cmd", "\n"); $c->find(array("x" => array("\ngt" => 4)));

Querying $posts = $blog->find(array( "author" => "Joe")); $commentsbyfred = $blog->find(array( "comments.author" => "Fred")); $commentsbyfred = $blog->find(array( "comments.author" => new MongoRegex("/fred/i")));

Speaking of indexing $people->ensureindex(array("age" => 1)); $people->ensureindex(array( "name" => -1, "ts" => -1, "comments.author" => 1 ));

Cursors $cursor = $c->find(array("foo" => "bar")) foreach($cursor as $id => $value) { }... $a = iterator_to_array($cursor);

Paging $page_num = 3; $results_per_page = 10; $cursor = $results->find() ->sort(array("ts" => -1)) ->skip($page_num * $results_per_page) ->limit($results_per_page);

BSON Binary Serializable Object Notation (Binary JSON) JS: { x : 4 } PHP: array("x" => 4) BSON: 0x0c 0x00 0x00 0x00 0x10 0x78 0x00 0x04 0x00 0x00 0x00 0x00 size type "x" 4 eoo

BSON $bson = bson_encode($mixed) $array = bson_decode($bson)

Applications

solimap @trackmeet FetLife Dextify 2

Starter App: Logging insert/update/remove is fast Capped collections Schemaless $inc for counts

Max: 4Mb Storing Files

(More than 4 Mb) Storing Files

Storing Files J J J J J J chunks J J J _id : J files

$fileid = new MongoId(); Storing Files $fileobj = array( '_id' => $fileid, 'filename' => "ggbridge.png", 'user' => "joe", 'takenin' => "San Francisco" ) $chunkobj = array( 'fileid' : $fileid, 'chunknum' : N 'data' : <binary data> )

Aggregation count, distinct, group =~ GROUP BY Map/Reduce $db->command(array( 'mapreduce' => <collection>, 'map' => <mapfunction>, 'reduce' => <reducefunction> [, 'query' => <query filter object>] [, 'out' => <outputcollectionname>] [, 'keeptemp' => <true false>] [, 'finalize' => <finalizefunction>] ))

JavaScript Functions in PHP $code = new MongoCode( "function() { return 'hello'; }"); $code = new MongoCode( "function() { return 'hello, '+name; }", array("name" => "Fred")); $db->execute($code);

JavaScript Functions in PHP $code = new MongoCode( "function(myname) { ". "return 'hello, '+name+', my name is '+myname;". "}", array("name" => "Fred") ); $db->execute($code, array("joe"));

One Last Bit of Mongo Philosophy User Support irc.freenode.net#mongodb http://groups.google.com/group/mongodb-user/ @mongodb

Thank you! kristina@php.net @kchodorow