MongoDB London PHP

50 %
50 %
Information about MongoDB London PHP

Published on July 2, 2009

Author: mdirolf



MongoDB talk from the July '09 London PHP meetup.

open-source, high-performance, schema-free, document-oriented database

RDBMS • Great for many applications • Shortcomings • Scalability • Flexibility

CAP Theorem • Consistency • Availability • Tolerance to network Partitions • Pick two

ACID vs BASE • Atomicity • Basically Available • Consistency • Soft state • Isolation • Eventually consistent • Durability

Schema-free • Loosening constraints - added flexibility • Dynamically typed languages • Migrations

BigTable • Single master node • Row / Column hybrid • Versioned

BigTable • Open-source clones: • HBase • Hypertable

Dynamo • Simple Key/Value store • No master node • Write to any (many) nodes • Read from one or more nodes (balance speed vs. consistency) • Read repair

Dynamo • Open-source clones • Project Voldemort • Cassandra - data model more like BigTable • Dynomite

memcached • Used as a caching layer • Essentially a key/value store • RAM only - fast • Does away with ACID

Redis • Like memcached • Different • Values can be strings, lists, sets • Non-volatile

Tokyo Cabinet + Tyrant • Key/value store with focus on speed • Some more advanced queries • Sorting, range or prefix matching • Multiple storage engines • Hash, B-Tree, Fixed length and Table

• A lot in common with MongoDB: • Document-oriented • Schema-free • JSON-style documents

• Differences • MVCC based • Replication as path to scalability • Query through predefined views • ACID • REST

• Focus on performance • Rich dynamic queries • Secondary indexes • Replication / failover • Auto-sharding • Many platforms / languages supported

Good at • The web • Caching • High volume / low value • Scalability

Less good at • Highly transactional • Ad-hoc business intelligence • Problems that require SQL

Mongo PHP Driver • PHP extension • Available on PECL pecl install mongo

Document • Unit of storage (think row) • Just an Array • Can store dates, integers, floating point, strings, etc.

Collection • Schema-free equivalent of a table • Logical groups of documents • Indexes are per-collection

Blog back-end

Post array(‘author’ => ‘mike’, ‘date’ => new MongoDate(), ‘text’ => ‘my blog post...’, ‘tags’ => array(‘mongodb’, ‘php’))

New post $doc = array(‘author’ => ‘mike’, ‘date’ => new MongoDate(), ‘text’ => ‘my blog post...’, ‘tags’ => array(‘mongodb’, ‘php’)); $collection->save($doc);

Last 10 posts $cursor = $posts->find()-> sort(array(‘date’=>-1))-> limit(10); foreach($cursor as $post) { echo $post[‘text’]; }

Posts by author $posts->find(array(‘author’=>‘mike’))

Posts ending with ‘PHP’ $posts->find(array(‘text’=>new MongoRegex(‘/PHP$/’)))

Posts with a tag $posts->find(array(‘tag’=>‘mongodb’)) ... and fast $posts->ensureIndex(array(‘tag’=>1))

Counting posts $posts->count() $posts->find(array(‘author’=>‘mike’))->count()

Migration: adding titles • Easy - just start adding them to documents

Advanced queries • $gt, $lt, $gte, $lte, $ne, $all, $in, $nin • $where clause “ == ‘mike’ || this.comments.length > 5” • group

Other cool stuff • Capped collections • Unique indexes • Mongo shell • GridFS • morph - mongodb-morph/

• Download MongoDB • Install the PHP Driver • Try it out!

• • • mongodb-user on google groups • @mongodb, @mdirolf • •

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

MongoDB for GIANT Ideas | MongoDB

MongoDB is the next-generation database that lets you create applications never before possible.
Read more

MongoDB for GIANT Ideas | MongoDB

MongoDB for GIANT Ideas - Build innovative modern applications that create a competitive advantage.
Read more

Do What You Could Never Do Before | MongoDB

MongoDB is the next-generation database that lets you do things you could never do before.
Read more

PHP and mongoDB - Home — Derick Rethans

About Me Derick Rethans Dutchman living in London PHP mongoDB driver maintainer for 10gen (the company behind mongoDB) Author of Xdebug Author of the ...
Read more

MongoDB Masters

MongoDB Masters MongoDB Masters is ... (while also dabbling in PHP). Katia has worked with MongoDB since 2010, ... and is a key member of the London Java ...
Read more

MongoDB - PHP

• I'm Dutch/British living in London • One of the PHP/HHVM MongoDB driver maintainers • Author of the PHP debugger tool Xdebug, ...
Read more

MongoDB - PHP Presents

• I'm Dutch/British living in London • One of the PHP/HHVM MongoDB driver maintainers • Author of the PHP debugger tool Xdebug, ...
Read more

php - MongoDB: How to query nested arrays? - Stack Overflow

I’m trying to build a simple blog system in PHP with MongoDB just to ... city": "London " }, "post ... a query, so you'll need to sort within PHP ...
Read more

Php / Mongodb | LinkedIn

View 958 Php / Mongodb posts, presentations, experts, and more. Get the professional knowledge you need on LinkedIn.
Read more