com presentations: New slides for DrupalCon.: mongo-drupalcon12.xml mongo-index-munich-mug.xml mongo-shefphp.xml
slides/map/finding-food-import-mongo.xml slides/mongodb/drupal-module-field-config.xml slides/mongodb/drupal-module-install.xml
slides/mongodb/drupal-module-mongo-storage.xml slides/mongodb/drupal-module-mysql-storage.xml slides/mongodb/drupal-module.xml
slides/mongodb/mongodb-drupal.jpg slides/mongodb/php-connection-string.xml slides/
| From: | Derick Rethans | Date: | Wed, 15 Aug 2012 15:47:07 +0000 |
| Subject: | com presentations: New slides for DrupalCon.: mongo-drupalcon12.xml mongo-index-munich-mug.xml mongo-shefphp.xml slides/map/finding-food-import-mongo.xml slides/mongodb/drupal-module-field-config.xml slides/mongodb/drupal-module-install.xml slides/mongodb/drupal-module-mongo-storage.xml slides/mongodb/drupal-module-mysql-storage.xml slides/mongodb/drupal-module.xml slides/mongodb/mongodb-drupal.jpg slides/mongodb/php-connection-string.xml slides/ |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1831@lists.php.net to get a copy of this message | ||
Commit: 914829e7726c3ef62207c28c5f3ba793f048b620
Author: Derick Rethans <github@derickrethans.nl> Wed, 15 Aug 2012 16:47:07 +0100
Parents: c46e01cef29a3704472df544a4ce19944784559c
Branches: master
Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=914829e7726c3ef62207c28c5f3ba793f048b620
Log:
New slides for DrupalCon..
Changed paths:
A mongo-drupalcon12.xml
A mongo-index-munich-mug.xml
A mongo-shefphp.xml
M slides/map/finding-food-import-mongo.xml
A slides/mongodb/drupal-module-field-config.xml
A slides/mongodb/drupal-module-install.xml
A slides/mongodb/drupal-module-mongo-storage.xml
A slides/mongodb/drupal-module-mysql-storage.xml
A slides/mongodb/drupal-module.xml
A slides/mongodb/mongodb-drupal.jpg
M slides/mongodb/php-connection-string.xml
M slides/mongodb/update.xml
diff --git a/mongo-drupalcon12.xml b/mongo-drupalcon12.xml new file mode 100644 index 0000000..789e353 --- /dev/null +++ b/mongo-drupalcon12.xml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="10gen-strict.css"> +<topic>mongoDB</topic> +<title>MongoDB Introduction</title> +<event>DrupalCon Munich 2012</event> +<location>Munich, Germany</location> +<date>Aug 23rd, 2012</date> +<speaker>Derick Rethans</speaker> +<email>derick@10gen.com</email> +<twitter>derickr</twitter> +<url>http://derickrethans.nl/talks.html</url> +<joindin>e-mail me</joindin> +<slide>slides/mongodb/title.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/mongodb/databasefield.xml</slide> +<slide>slides/mongodb/collections-documents.xml</slide> +<slide>slides/mongodb/document.xml</slide> + +Common Patterns + +- RDBMS-normalisation. + +<slide>slides/mongodb/blog.xml</slide> +<slide>slides/mongodb/blog2.xml</slide> + +<slide>slides/mongodb/considerations.xml</slide> + +**OSMify** +<slide>slides/mongodb/inherit.xml</slide> +<slide>slides/mongodb/inherit-rdbms.xml</slide> +<slide>slides/mongodb/inherit-mongo.xml</slide> +<slide>slides/mongodb/inherit-summary.xml</slide> + +<slide>slides/mongodb/osm-to-mongo-data.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data2.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data3.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data4.xml</slide> +<slide>slides/map/finding-food-import-mongo.xml</slide> + +<slide>slides/mongodb/embed-vs-link.xml</slide> + +<!-- DRUPAL SPECIFIC PART --> +<slide>slides/mongodb/drupal-module.xml</slide> +<slide>slides/mongodb/drupal-module-install.xml</slide> +<slide>slides/mongodb/drupal-module-field-config.xml</slide> +<slide>slides/mongodb/drupal-module-mysql-storage.xml</slide> +<slide>slides/mongodb/drupal-module-mongo-storage.xml</slide> + +<slide>slides/mongodb/replication.xml</slide> +- setup +- slaveOk +- journal +- write concerns +- tags (mention briefly) +- php connection string + +<slide>slides/mongodb/sharding.xml</slide> +- mongos +- diagram +- transparent + +<slide>slides/mongodb/idx-startup-quotes.xml</slide> + +<slide>slides/mongodb/idx-create.xml</slide> + +<slide>slides/mongodb/idx-cities-by-name.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop2.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem2.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem4.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem6.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem5.xml</slide> + +<slide>slides/mongodb/idx-recap1.xml</slide> +<slide>slides/mongodb/idx-recap2.xml</slide> +<slide>slides/mongodb/idx-recap3.xml</slide> +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/mongo-index-munich-mug.xml b/mongo-index-munich-mug.xml new file mode 100644 index 0000000..be5d1e2 --- /dev/null +++ b/mongo-index-munich-mug.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="10gen-strict.css"> +<topic>mongoDB</topic> +<title>Indexing and Query Optimisation</title> +<event>München MongoDB User Group</event> +<location>Munich, Germany</location> +<date>Aug 21st, 2012</date> +<speaker>Derick Rethans</speaker> +<email>derick@10gen.com</email> +<twitter>derickr</twitter> +<url>http://derickrethans.nl/talks.html</url> +<joindin>e-mail me!</joindin> + +<!-- +sleep 4; for i in `seq 0 39`; do firefox http://pres/show2.php/mongo-index-munich-mug/$i; sleep 3; import -window 0x4200077 /tmp/win$i.jpg; done +--> + +<slide>slides/mongodb/title.xml</slide> +<slide>slides/mongodb/idx-whats-in-store.xml</slide> +<slide>slides/mongodb/idx-startup-quotes.xml</slide> +<slide>slides/mongodb/idx-startup-quotes2.xml</slide> +<slide>slides/mongodb/idx-startup-quotes3.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/mongodb/idx-map.xml</slide> +<slide>slides/mongodb/idx-how-do-you-find-a-city.xml</slide> +<slide>slides/mongodb/idx-create.xml</slide> + +<slide>slides/mongodb/idx-cities-by-name.xml</slide> +<slide>slides/mongodb/idx-how-do-you-find-a-large-city.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop2.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop3.xml</slide> +<slide>slides/mongodb/idx-how-do-you-find-a-large-city-on-a-mountain.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem2.xml</slide> +<slide>slides/mongodb/idx-stored.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem3.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem4.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem6.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem5.xml</slide> + +<slide>slides/mongodb/idx-recap1.xml</slide> +<slide>slides/mongodb/idx-recap2.xml</slide> + + +<slide>slides/mongodb/idx-options.xml</slide> +<slide>slides/mongodb/idx-unique.xml</slide> +<slide>slides/mongodb/idx-sparse.xml</slide> +<slide>slides/mongodb/idx-sparse2.xml</slide> +<slide>slides/mongodb/idx-covered.xml</slide> +<slide>slides/mongodb/idx-multi-key.xml</slide> +<slide>slides/mongodb/idx-which-one-is-picked.xml</slide> +<slide>slides/mongodb/idx-or.xml</slide> + +<slide>slides/mongodb/idx-map2.xml</slide> +<slide>slides/mongodb/idx-geo.xml</slide> +<slide>slides/mongodb/idx-geo2.xml</slide> +<slide>slides/mongodb/idx-geo-geohash.xml</slide> +<slide>slides/mongodb/idx-geo3.xml</slide> +<slide>slides/mongodb/idx-geo4.xml</slide> + +unique +sparse +indexonly +multikey +2d + +<slide>slides/mongodb/idx-recap3.xml</slide> + +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/mongo-shefphp.xml b/mongo-shefphp.xml new file mode 100644 index 0000000..46c2b69 --- /dev/null +++ b/mongo-shefphp.xml @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="10gen-strict.css"> +<topic>mongoDB</topic> +<title>MongoDB</title> +<event>Sheffield PHP</event> +<location>Sheffield, UK</location> +<date>Jul 11th, 2012</date> +<speaker>Derick Rethans</speaker> +<email>derick@10gen.com</email> +<twitter>derickr</twitter> +<url>http://derickrethans.nl/talks.html</url> +<joindin></joindin> +<slide>slides/mongodb/title.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/mongodb/databasefield.xml</slide> +<slide>slides/mongodb/collections-documents.xml</slide> +<slide>slides/mongodb/document.xml</slide> + +<slide>slides/mongodb/types.xml</slide> +- php types +- extra types (int32/64) +- id +<slide>slides/mongodb/id.xml</slide> +<slide>slides/mongodb/safe2.xml</slide> + +<slide>slides/mongodb/cursors.xml</slide> +- cursor +<slide>slides/mongodb/limit-skip.xml</slide> +- limit/skip + + +<slide>slides/mongodb/update2a.xml</slide> + +<!-- SCHEMA DESIGN --> +Common Patterns + +- RDBMS-normalisation. + +<slide>slides/mongodb/blog.xml</slide> +<slide>slides/mongodb/blog2.xml</slide> + +<slide>slides/mongodb/considerations.xml</slide> + +<slide>slides/mongodb/inherit.xml</slide> +<slide>slides/mongodb/inherit-rdbms.xml</slide> +<slide>slides/mongodb/inherit-mongo.xml</slide> +<slide>slides/mongodb/inherit-summary.xml</slide> + +<slide>slides/mongodb/osm-to-mongo-data.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data2.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data3.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data4.xml</slide> +<slide>slides/map/finding-food-import-mongo.xml</slide> + +<slide>slides/mongodb/one-to-many1.xml</slide> +<slide>slides/mongodb/one-to-many2.xml</slide> +<slide>slides/mongodb/one-to-many4.xml</slide> +<slide>slides/mongodb/one-to-many3.xml</slide> + +<slide>slides/mongodb/many-to-many1.xml</slide> +<slide>slides/mongodb/many-to-many2.xml</slide> +<slide>slides/mongodb/many-to-many3.xml</slide> + +<slide>slides/mongodb/embed-vs-link.xml</slide> + +<slide>slides/mongodb/idx-recap1.xml</slide> +<slide>slides/mongodb/idx-recap2.xml</slide> +<slide>slides/mongodb/idx-recap3.xml</slide> + + +<slide>slides/mongodb/replication.xml</slide> +<slide>slides/mongodb/replication-setup.xml</slide> +<slide>slides/mongodb/php-connection-string.xml</slide> +- setup +- slaveOk +- journal +- write concerns +<slide>slides/mongodb/safe3.xml</slide> +<slide>slides/mongodb/read-preference.xml</slide> + +<slide>slides/mongodb/mmap.xml</slide> +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/slides/map/finding-food-import-mongo.xml b/slides/map/finding-food-import-mongo.xml index 74ade27..18b6a11 100644 --- a/slides/map/finding-food-import-mongo.xml +++ b/slides/map/finding-food-import-mongo.xml @@ -1,24 +1,71 @@ <slide> <title>Think about the data schema!</title> +<div effect="fade-out"> <example>$doc = array( - 'name' => 'A440', - 'tags = [ - 'highway' => 'secondary', - 'oneway' => 'yes' - ] + 'name' => 'A440', + 'tags => [ + 'highway' => 'secondary', + 'oneway' => 'yes' + ] ); $db->poi->ensureIndex( [ 'name' => 1 ] ); $db->poi->ensureIndex( [ 'tags.highway' => 1 ] ); -$db->poi->ensureIndex( [ 'tags.oneway' => 1 ] );</example> +$db->poi->ensureIndex( [ 'tags.oneway' => 1 ] ); + +// Road with name=Strand +$db->poi->find( [ 'name' => 'Strand' ] ); +// All roads +$db->poi->find( [ 'tags.highway' => [ '$exists' => 1 ] ] ); +</example> +<list> + <bullet>Lots of indexed are required</bullet> + <bullet>Easy to extract data from</bullet> +</list> +</div> +<div effect="fade-in-out"> <blurb>or:</blurb> <example>$doc = array( - 'name' => 'A440', - 'tags' = [ - { 'k' => 'highway', 'v' => 'secondary' }, - { 'k' => 'oneway', 'v' => 'yes' } - ] + 'tags' => [ + [ 'k' => 'name', 'v' => 'A440' ], + [ 'k' => 'highway', 'v' => 'secondary' ], + [ 'k' => 'oneway', 'v' => 'yes' ] + ] ); -$db->poi->ensureIndex( [ 'name' => 1 ] ); -$db->poi->ensureIndex( [ 'tags.k' => 1, 'tags.v' => 1 ] );</example> +$db->poi->ensureIndex( [ 'tags.v' => 1, 'tags.k' => 1 ] ); + +// Road with name=Strand +$db->poi->find( [ + 'tags' => [ '$elemMatch' => [ 'k' : 'name', 'v' : 'Strand' ] ] +] ); +// All roads +$db->poi->find( [ 'tags.k' => 'highway' ] ); +</example> +<list> + <bullet>One index required</bullet> + <bullet>Good for finding key/value combinations</bullet> + <bullet>Extra index needed for "all roads" question (on %tags_indexed.k%)</bullet> +</list> +</div> +<div effect="fade-in"> +<blurb>or:</blurb> +<example>$doc = array( + 'tags' => [ + 'name=A440', + 'highway=secondary', + 'oneway=yes' + ] +); +$db->poi->ensureIndex( [ 'tags' => 1 ] ); + +// Road with name=Strand +$db->poi->find( [ 'tags' => 'name=Strand' ] ); +// All roads +$db->poi->find( [ 'tags' => new MongoRegex( '/^highway=/' ) ] );</example> +<list> + <bullet>One index required</bullet> + <bullet>Good for finding key/value combinations</bullet> + <bullet>Good enough for doing the "all roads" question</bullet> +</list> +</div> </slide> diff --git a/slides/mongodb/drupal-module-field-config.xml b/slides/mongodb/drupal-module-field-config.xml new file mode 100644 index 0000000..4df35c5 --- /dev/null +++ b/slides/mongodb/drupal-module-field-config.xml @@ -0,0 +1,35 @@ +<slide> +<title>Field configuration overview</title> +<example> +mysql> select * from field_config where field_name like 'field_author%' \G +*************************** 1. row *************************** + id: 5 + field_name: field_author + type: text + module: text + active: 1 + storage_type: mongodb_field_storage +storage_module: mongodb_field_storage +storage_active: 0 + locked: 0 + data: a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:1:{s:10:"max_length";s:3:"255";}s:7:"storage";a:5:{s:4:"type";s:21:"mongodb_field_storage";s:8:"settings";a:0:{}s:6:"module";s:21:"mongodb_field_storage";s:6:"active";s:1:"1";s:7:"details";a:0:{}}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:2:"id";s:1:"5";} + cardinality: -1 + translatable: 0 + deleted: 0 +*************************** 2. row *************************** + id: 6 + field_name: field_author2 + type: text + module: text + active: 1 + storage_type: field_sql_storage +storage_module: field_sql_storage +storage_active: 1 + locked: 0 + data: a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:1:{s:10:"max_length";s:3:"255";}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:24:"field_data_field_author2";a:2:{s:5:"value";s:19:"field_author2_value";s:6:"format";s:20:"field_author2_format";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:28:"field_revision_field_author2";a:2:{s:5:"value";s:19:"field_author2_value";s:6:"format";s:20:"field_author2_format";}}}}}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:2:"id";s:1:"6";} + cardinality: -1 + translatable: 0 + deleted: 0 +2 rows in set (0.00 sec) +</example> +</slide> diff --git a/slides/mongodb/drupal-module-install.xml b/slides/mongodb/drupal-module-install.xml new file mode 100644 index 0000000..72ddabf --- /dev/null +++ b/slides/mongodb/drupal-module-install.xml @@ -0,0 +1,11 @@ +<slide> +<title>Installing the module</title> + +<list> + <bullet>Download from http://ftp.drupal.org/files/projects/mongodb-7.x-1.0-rc1.tar.gz</bullet> + <bullet>Extract in %sites/all/modules/%</bullet> + <bullet>Enable in %http://drupal/#overlay=\%3Fq\%3Dadmin/modules%</bullet> +</list> + +<image filename="mongodb-drupal.jpg"/> +</slide> diff --git a/slides/mongodb/drupal-module-mongo-storage.xml b/slides/mongodb/drupal-module-mongo-storage.xml new file mode 100644 index 0000000..27c5113 --- /dev/null +++ b/slides/mongodb/drupal-module-mongo-storage.xml @@ -0,0 +1,52 @@ +<slide> +<title>Storing node/fields in MongoDB</title> +<example> +mysql> select * from node where nid = 3\G +*************************** 1. row *************************** + nid: 3 + vid: 3 + type: book + language: und + title: A book with some more fields + uid: 1 + status: 1 + created: 1345026957 + changed: 1345027893 + comment: 2 + promote: 1 + sticky: 0 + tnid: 0 +translate: 0 +1 row in set (0.00 sec) +</example><example> +> db['fields_current.node'].find( { 'nid' : 3 } ).pretty(); +{ + "_id" : NumberLong(3), + "_type" : "node", + "_bundle" : "book", + "_revision_id" : NumberLong(3), + "nid" : NumberLong(3), + "vid" : NumberLong(3), + "type" : "book", + "language" : "und", + "title" : "A book with some more fields", + "uid" : NumberLong(1), + "status" : NumberLong(1), + "created" : NumberLong(1345026957), + "changed" : NumberLong(1345027893), + "comment" : NumberLong(2), + "promote" : NumberLong(1), + "sticky" : NumberLong(0), + "tnid" : NumberLong(0), + "translate" : NumberLong(0), + "field_author" : [ + { + "value" : "Derick Rethans" + }, + { + "value" : "Hannes Magnusson" + } + ] +} +</example> +</slide> diff --git a/slides/mongodb/drupal-module-mysql-storage.xml b/slides/mongodb/drupal-module-mysql-storage.xml new file mode 100644 index 0000000..0a5fd11 --- /dev/null +++ b/slides/mongodb/drupal-module-mysql-storage.xml @@ -0,0 +1,31 @@ +<slide> +<title>Storing node/fields in MySQL</title> +<example> +mysql> select * from node where nid = 5\G +*************************** 1. row *************************** + nid: 5 + vid: 5 + type: book + language: und + title: PHP 5 Power Programming + uid: 1 + status: 1 + created: 1345034378 + changed: 1345034395 + comment: 2 + promote: 1 + sticky: 0 + tnid: 0 +translate: 0 +1 row in set (0.00 sec) +</example><example> +mysql> select * from field_data_field_author2 where entity_id = 5; ++-------------+--------+---------+-----------+-------------+----------+-------+---------------------+----------------------+ +| entity_type | bundle | deleted | entity_id | revision_id | language | delta | field_author2_value | field_author2_format | ++-------------+--------+---------+-----------+-------------+----------+-------+---------------------+----------------------+ +| node | book | 0 | 5 | 5 | und | 0 | Derick Rethans | NULL | +| node | book | 0 | 5 | 5 | und | 1 | Hannes Magnusson | NULL | ++-------------+--------+---------+-----------+-------------+----------+-------+---------------------+----------------------+ +2 rows in set (0.00 sec) +</example> +</slide> diff --git a/slides/mongodb/drupal-module.xml b/slides/mongodb/drupal-module.xml new file mode 100644 index 0000000..02313c0 --- /dev/null +++ b/slides/mongodb/drupal-module.xml @@ -0,0 +1,18 @@ +<slide> +<title>Drupal and MongoDB</title> + +<blurb>http://drupal.org/project/mongodb - a MongoDB module for Drupal</blurb> +<list> + <bullet>Provides basic functionality for using MongoDB with Drupal</bullet> + <bullet>Support for: Sessions, Watchdog, Block, Queue, Cache and Field storage</bullet> +</list> +<break/> + +<blurb>http://drupal.org/project/mongodb_dbtng - an *experimental* DBTNG driver</blurb> +<list> + <bullet>Parses the SQL and translates it to MongoDB structures and queries</bullet> +</list> +<break/> + +<blurb>Drupal 8 might support MongoDB natively...</blurb> +</slide> diff --git a/slides/mongodb/mongodb-drupal.jpg b/slides/mongodb/mongodb-drupal.jpg new file mode 100644 index 0000000..413a7ff Binary files /dev/null and b/slides/mongodb/mongodb-drupal.jpg differ diff --git a/slides/mongodb/php-connection-string.xml b/slides/mongodb/php-connection-string.xml index fdd06e8..9b3cf31 100644 --- a/slides/mongodb/php-connection-string.xml +++ b/slides/mongodb/php-connection-string.xml @@ -4,11 +4,11 @@ <example result="0"><![CDATA[<?php $options = array( 'replicaSet' => 'seta' ); -$m = new Mongo( 'mongodb://localhost:13000', $options ); +$m = new Mongo( 'mongodb://user:password@localhost:13000/demo', $options ); $m = new Mongo( 'mongodb://localhost:13000,localhost:13001', $options ); -$m = new Mongo( 'mongodb://user:password@localhost:13000,localhost:13001/demo', $options ); +$m = new Mongo( 'mongodb://localhost:13000,localhost:13001', $options ); ?>]]></example> <list> diff --git a/slides/mongodb/update.xml b/slides/mongodb/update.xml index 60d051e..ac2290d 100644 --- a/slides/mongodb/update.xml +++ b/slides/mongodb/update.xml @@ -1,7 +1,7 @@ <slide> <title>Updating documents</title> -<example result="0"><![CDATA[<?php +<example result="1"><![CDATA[<?php $m = new Mongo; $c = $m->demo->elephpants; $c->remove();
diff --git a/mongo-drupalcon12.xml b/mongo-drupalcon12.xml new file mode 100644 index 0000000..789e353 --- /dev/null +++ b/mongo-drupalcon12.xml @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="10gen-strict.css"> +<topic>mongoDB</topic> +<title>MongoDB Introduction</title> +<event>DrupalCon Munich 2012</event> +<location>Munich, Germany</location> +<date>Aug 23rd, 2012</date> +<speaker>Derick Rethans</speaker> +<email>derick@10gen.com</email> +<twitter>derickr</twitter> +<url>http://derickrethans.nl/talks.html</url> +<joindin>e-mail me</joindin> +<slide>slides/mongodb/title.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/mongodb/databasefield.xml</slide> +<slide>slides/mongodb/collections-documents.xml</slide> +<slide>slides/mongodb/document.xml</slide> + +Common Patterns + +- RDBMS-normalisation. + +<slide>slides/mongodb/blog.xml</slide> +<slide>slides/mongodb/blog2.xml</slide> + +<slide>slides/mongodb/considerations.xml</slide> + +**OSMify** +<slide>slides/mongodb/inherit.xml</slide> +<slide>slides/mongodb/inherit-rdbms.xml</slide> +<slide>slides/mongodb/inherit-mongo.xml</slide> +<slide>slides/mongodb/inherit-summary.xml</slide> + +<slide>slides/mongodb/osm-to-mongo-data.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data2.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data3.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data4.xml</slide> +<slide>slides/map/finding-food-import-mongo.xml</slide> + +<slide>slides/mongodb/embed-vs-link.xml</slide> + +<!-- DRUPAL SPECIFIC PART --> +<slide>slides/mongodb/drupal-module.xml</slide> +<slide>slides/mongodb/drupal-module-install.xml</slide> +<slide>slides/mongodb/drupal-module-field-config.xml</slide> +<slide>slides/mongodb/drupal-module-mysql-storage.xml</slide> +<slide>slides/mongodb/drupal-module-mongo-storage.xml</slide> + +<slide>slides/mongodb/replication.xml</slide> +- setup +- slaveOk +- journal +- write concerns +- tags (mention briefly) +- php connection string + +<slide>slides/mongodb/sharding.xml</slide> +- mongos +- diagram +- transparent + +<slide>slides/mongodb/idx-startup-quotes.xml</slide> + +<slide>slides/mongodb/idx-create.xml</slide> + +<slide>slides/mongodb/idx-cities-by-name.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop2.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem2.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem4.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem6.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem5.xml</slide> + +<slide>slides/mongodb/idx-recap1.xml</slide> +<slide>slides/mongodb/idx-recap2.xml</slide> +<slide>slides/mongodb/idx-recap3.xml</slide> +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/mongo-index-munich-mug.xml b/mongo-index-munich-mug.xml new file mode 100644 index 0000000..be5d1e2 --- /dev/null +++ b/mongo-index-munich-mug.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="10gen-strict.css"> +<topic>mongoDB</topic> +<title>Indexing and Query Optimisation</title> +<event>München MongoDB User Group</event> +<location>Munich, Germany</location> +<date>Aug 21st, 2012</date> +<speaker>Derick Rethans</speaker> +<email>derick@10gen.com</email> +<twitter>derickr</twitter> +<url>http://derickrethans.nl/talks.html</url> +<joindin>e-mail me!</joindin> + +<!-- +sleep 4; for i in `seq 0 39`; do firefox http://pres/show2.php/mongo-index-munich-mug/$i; sleep 3; import -window 0x4200077 /tmp/win$i.jpg; done +--> + +<slide>slides/mongodb/title.xml</slide> +<slide>slides/mongodb/idx-whats-in-store.xml</slide> +<slide>slides/mongodb/idx-startup-quotes.xml</slide> +<slide>slides/mongodb/idx-startup-quotes2.xml</slide> +<slide>slides/mongodb/idx-startup-quotes3.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/mongodb/idx-map.xml</slide> +<slide>slides/mongodb/idx-how-do-you-find-a-city.xml</slide> +<slide>slides/mongodb/idx-create.xml</slide> + +<slide>slides/mongodb/idx-cities-by-name.xml</slide> +<slide>slides/mongodb/idx-how-do-you-find-a-large-city.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop2.xml</slide> +<slide>slides/mongodb/idx-cities-by-name-and-pop3.xml</slide> +<slide>slides/mongodb/idx-how-do-you-find-a-large-city-on-a-mountain.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem2.xml</slide> +<slide>slides/mongodb/idx-stored.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem3.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem4.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem6.xml</slide> +<slide>slides/mongodb/idx-cities-by-pop-and-dem5.xml</slide> + +<slide>slides/mongodb/idx-recap1.xml</slide> +<slide>slides/mongodb/idx-recap2.xml</slide> + + +<slide>slides/mongodb/idx-options.xml</slide> +<slide>slides/mongodb/idx-unique.xml</slide> +<slide>slides/mongodb/idx-sparse.xml</slide> +<slide>slides/mongodb/idx-sparse2.xml</slide> +<slide>slides/mongodb/idx-covered.xml</slide> +<slide>slides/mongodb/idx-multi-key.xml</slide> +<slide>slides/mongodb/idx-which-one-is-picked.xml</slide> +<slide>slides/mongodb/idx-or.xml</slide> + +<slide>slides/mongodb/idx-map2.xml</slide> +<slide>slides/mongodb/idx-geo.xml</slide> +<slide>slides/mongodb/idx-geo2.xml</slide> +<slide>slides/mongodb/idx-geo-geohash.xml</slide> +<slide>slides/mongodb/idx-geo3.xml</slide> +<slide>slides/mongodb/idx-geo4.xml</slide> + +unique +sparse +indexonly +multikey +2d + +<slide>slides/mongodb/idx-recap3.xml</slide> + +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/mongo-shefphp.xml b/mongo-shefphp.xml new file mode 100644 index 0000000..46c2b69 --- /dev/null +++ b/mongo-shefphp.xml @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="10gen-strict.css"> +<topic>mongoDB</topic> +<title>MongoDB</title> +<event>Sheffield PHP</event> +<location>Sheffield, UK</location> +<date>Jul 11th, 2012</date> +<speaker>Derick Rethans</speaker> +<email>derick@10gen.com</email> +<twitter>derickr</twitter> +<url>http://derickrethans.nl/talks.html</url> +<joindin></joindin> +<slide>slides/mongodb/title.xml</slide> +<slide>slides/mongodb/me.xml</slide> + +<slide>slides/mongodb/databasefield.xml</slide> +<slide>slides/mongodb/collections-documents.xml</slide> +<slide>slides/mongodb/document.xml</slide> + +<slide>slides/mongodb/types.xml</slide> +- php types +- extra types (int32/64) +- id +<slide>slides/mongodb/id.xml</slide> +<slide>slides/mongodb/safe2.xml</slide> + +<slide>slides/mongodb/cursors.xml</slide> +- cursor +<slide>slides/mongodb/limit-skip.xml</slide> +- limit/skip + + +<slide>slides/mongodb/update2a.xml</slide> + +<!-- SCHEMA DESIGN --> +Common Patterns + +- RDBMS-normalisation. + +<slide>slides/mongodb/blog.xml</slide> +<slide>slides/mongodb/blog2.xml</slide> + +<slide>slides/mongodb/considerations.xml</slide> + +<slide>slides/mongodb/inherit.xml</slide> +<slide>slides/mongodb/inherit-rdbms.xml</slide> +<slide>slides/mongodb/inherit-mongo.xml</slide> +<slide>slides/mongodb/inherit-summary.xml</slide> + +<slide>slides/mongodb/osm-to-mongo-data.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data2.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data3.xml</slide> +<slide>slides/mongodb/osm-to-mongo-data4.xml</slide> +<slide>slides/map/finding-food-import-mongo.xml</slide> + +<slide>slides/mongodb/one-to-many1.xml</slide> +<slide>slides/mongodb/one-to-many2.xml</slide> +<slide>slides/mongodb/one-to-many4.xml</slide> +<slide>slides/mongodb/one-to-many3.xml</slide> + +<slide>slides/mongodb/many-to-many1.xml</slide> +<slide>slides/mongodb/many-to-many2.xml</slide> +<slide>slides/mongodb/many-to-many3.xml</slide> + +<slide>slides/mongodb/embed-vs-link.xml</slide> + +<slide>slides/mongodb/idx-recap1.xml</slide> +<slide>slides/mongodb/idx-recap2.xml</slide> +<slide>slides/mongodb/idx-recap3.xml</slide> + + +<slide>slides/mongodb/replication.xml</slide> +<slide>slides/mongodb/replication-setup.xml</slide> +<slide>slides/mongodb/php-connection-string.xml</slide> +- setup +- slaveOk +- journal +- write concerns +<slide>slides/mongodb/safe3.xml</slide> +<slide>slides/mongodb/read-preference.xml</slide> + +<slide>slides/mongodb/mmap.xml</slide> +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/slides/map/finding-food-import-mongo.xml b/slides/map/finding-food-import-mongo.xml index 74ade27..18b6a11 100644 --- a/slides/map/finding-food-import-mongo.xml +++ b/slides/map/finding-food-import-mongo.xml @@ -1,24 +1,71 @@ <slide> <title>Think about the data schema!</title> +<div effect="fade-out"> <example>$doc = array( - 'name' => 'A440', - 'tags = [ - 'highway' => 'secondary', - 'oneway' => 'yes' - ] + 'name' => 'A440', + 'tags => [ + 'highway' => 'secondary', + 'oneway' => 'yes' + ] ); $db->poi->ensureIndex( [ 'name' => 1 ] ); $db->poi->ensureIndex( [ 'tags.highway' => 1 ] ); -$db->poi->ensureIndex( [ 'tags.oneway' => 1 ] );</example> +$db->poi->ensureIndex( [ 'tags.oneway' => 1 ] ); + +// Road with name=Strand +$db->poi->find( [ 'name' => 'Strand' ] ); +// All roads +$db->poi->find( [ 'tags.highway' => [ '$exists' => 1 ] ] ); +</example> +<list> + <bullet>Lots of indexed are required</bullet> + <bullet>Easy to extract data from</bullet> +</list> +</div> +<div effect="fade-in-out"> <blurb>or:</blurb> <example>$doc = array( - 'name' => 'A440', - 'tags' = [ - { 'k' => 'highway', 'v' => 'secondary' }, - { 'k' => 'oneway', 'v' => 'yes' } - ] + 'tags' => [ + [ 'k' => 'name', 'v' => 'A440' ], + [ 'k' => 'highway', 'v' => 'secondary' ], + [ 'k' => 'oneway', 'v' => 'yes' ] + ] ); -$db->poi->ensureIndex( [ 'name' => 1 ] ); -$db->poi->ensureIndex( [ 'tags.k' => 1, 'tags.v' => 1 ] );</example> +$db->poi->ensureIndex( [ 'tags.v' => 1, 'tags.k' => 1 ] ); + +// Road with name=Strand +$db->poi->find( [ + 'tags' => [ '$elemMatch' => [ 'k' : 'name', 'v' : 'Strand' ] ] +] ); +// All roads +$db->poi->find( [ 'tags.k' => 'highway' ] ); +</example> +<list> + <bullet>One index required</bullet> + <bullet>Good for finding key/value combinations</bullet> + <bullet>Extra index needed for "all roads" question (on %tags_indexed.k%)</bullet> +</list> +</div> +<div effect="fade-in"> +<blurb>or:</blurb> +<example>$doc = array( + 'tags' => [ + 'name=A440', + 'highway=secondary', + 'oneway=yes' + ] +); +$db->poi->ensureIndex( [ 'tags' => 1 ] ); + +// Road with name=Strand +$db->poi->find( [ 'tags' => 'name=Strand' ] ); +// All roads +$db->poi->find( [ 'tags' => new MongoRegex( '/^highway=/' ) ] );</example> +<list> + <bullet>One index required</bullet> + <bullet>Good for finding key/value combinations</bullet> + <bullet>Good enough for doing the "all roads" question</bullet> +</list> +</div> </slide> diff --git a/slides/mongodb/drupal-module-field-config.xml b/slides/mongodb/drupal-module-field-config.xml new file mode 100644 index 0000000..4df35c5 --- /dev/null +++ b/slides/mongodb/drupal-module-field-config.xml @@ -0,0 +1,35 @@ +<slide> +<title>Field configuration overview</title> +<example> +mysql> select * from field_config where field_name like 'field_author%' \G +*************************** 1. row *************************** + id: 5 + field_name: field_author + type: text + module: text + active: 1 + storage_type: mongodb_field_storage +storage_module: mongodb_field_storage +storage_active: 0 + locked: 0 + data: a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:1:{s:10:"max_length";s:3:"255";}s:7:"storage";a:5:{s:4:"type";s:21:"mongodb_field_storage";s:8:"settings";a:0:{}s:6:"module";s:21:"mongodb_field_storage";s:6:"active";s:1:"1";s:7:"details";a:0:{}}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:2:"id";s:1:"5";} + cardinality: -1 + translatable: 0 + deleted: 0 +*************************** 2. row *************************** + id: 6 + field_name: field_author2 + type: text + module: text + active: 1 + storage_type: field_sql_storage +storage_module: field_sql_storage +storage_active: 1 + locked: 0 + data: a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:1:{s:10:"max_length";s:3:"255";}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:24:"field_data_field_author2";a:2:{s:5:"value";s:19:"field_author2_value";s:6:"format";s:20:"field_author2_format";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:28:"field_revision_field_author2";a:2:{s:5:"value";s:19:"field_author2_value";s:6:"format";s:20:"field_author2_format";}}}}}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:2:"id";s:1:"6";} + cardinality: -1 + translatable: 0 + deleted: 0 +2 rows in set (0.00 sec) +</example> +</slide> diff --git a/slides/mongodb/drupal-module-install.xml b/slides/mongodb/drupal-module-install.xml new file mode 100644 index 0000000..72ddabf --- /dev/null +++ b/slides/mongodb/drupal-module-install.xml @@ -0,0 +1,11 @@ +<slide> +<title>Installing the module</title> + +<list> + <bullet>Download from http://ftp.drupal.org/files/projects/mongodb-7.x-1.0-rc1.tar.gz</bullet> + <bullet>Extract in %sites/all/modules/%</bullet> + <bullet>Enable in %http://drupal/#overlay=\%3Fq\%3Dadmin/modules%</bullet> +</list> + +<image filename="mongodb-drupal.jpg"/> +</slide> diff --git a/slides/mongodb/drupal-module-mongo-storage.xml b/slides/mongodb/drupal-module-mongo-storage.xml new file mode 100644 index 0000000..27c5113 --- /dev/null +++ b/slides/mongodb/drupal-module-mongo-storage.xml @@ -0,0 +1,52 @@ +<slide> +<title>Storing node/fields in MongoDB</title> +<example> +mysql> select * from node where nid = 3\G +*************************** 1. row *************************** + nid: 3 + vid: 3 + type: book + language: und + title: A book with some more fields + uid: 1 + status: 1 + created: 1345026957 + changed: 1345027893 + comment: 2 + promote: 1 + sticky: 0 + tnid: 0 +translate: 0 +1 row in set (0.00 sec) +</example><example> +> db['fields_current.node'].find( { 'nid' : 3 } ).pretty(); +{ + "_id" : NumberLong(3), + "_type" : "node", + "_bundle" : "book", + "_revision_id" : NumberLong(3), + "nid" : NumberLong(3), + "vid" : NumberLong(3), + "type" : "book", + "language" : "und", + "title" : "A book with some more fields", + "uid" : NumberLong(1), + "status" : NumberLong(1), + "created" : NumberLong(1345026957), + "changed" : NumberLong(1345027893), + "comment" : NumberLong(2), + "promote" : NumberLong(1), + "sticky" : NumberLong(0), + "tnid" : NumberLong(0), + "translate" : NumberLong(0), + "field_author" : [ + { + "value" : "Derick Rethans" + }, + { + "value" : "Hannes Magnusson" + } + ] +} +</example> +</slide> diff --git a/slides/mongodb/drupal-module-mysql-storage.xml b/slides/mongodb/drupal-module-mysql-storage.xml new file mode 100644 index 0000000..0a5fd11 --- /dev/null +++ b/slides/mongodb/drupal-module-mysql-storage.xml @@ -0,0 +1,31 @@ +<slide> +<title>Storing node/fields in MySQL</title> +<example> +mysql> select * from node where nid = 5\G +*************************** 1. row *************************** + nid: 5 + vid: 5 + type: book + language: und + title: PHP 5 Power Programming + uid: 1 + status: 1 + created: 1345034378 + changed: 1345034395 + comment: 2 + promote: 1 + sticky: 0 + tnid: 0 +translate: 0 +1 row in set (0.00 sec) +</example><example> +mysql> select * from field_data_field_author2 where entity_id = 5; ++-------------+--------+---------+-----------+-------------+----------+-------+---------------------+----------------------+ +| entity_type | bundle | deleted | entity_id | revision_id | language | delta | field_author2_value | field_author2_format | ++-------------+--------+---------+-----------+-------------+----------+-------+---------------------+----------------------+ +| node | book | 0 | 5 | 5 | und | 0 | Derick Rethans | NULL | +| node | book | 0 | 5 | 5 | und | 1 | Hannes Magnusson | NULL | ++-------------+--------+---------+-----------+-------------+----------+-------+---------------------+----------------------+ +2 rows in set (0.00 sec) +</example> +</slide> diff --git a/slides/mongodb/drupal-module.xml b/slides/mongodb/drupal-module.xml new file mode 100644 index 0000000..02313c0 --- /dev/null +++ b/slides/mongodb/drupal-module.xml @@ -0,0 +1,18 @@ +<slide> +<title>Drupal and MongoDB</title> + +<blurb>http://drupal.org/project/mongodb - a MongoDB module for Drupal</blurb> +<list> + <bullet>Provides basic functionality for using MongoDB with Drupal</bullet> + <bullet>Support for: Sessions, Watchdog, Block, Queue, Cache and Field storage</bullet> +</list> +<break/> + +<blurb>http://drupal.org/project/mongodb_dbtng - an *experimental* DBTNG driver</blurb> +<list> + <bullet>Parses the SQL and translates it to MongoDB structures and queries</bullet> +</list> +<break/> + +<blurb>Drupal 8 might support MongoDB natively...</blurb> +</slide> diff --git a/slides/mongodb/mongodb-drupal.jpg b/slides/mongodb/mongodb-drupal.jpg new file mode 100644 index 0000000..413a7ff Binary files /dev/null and b/slides/mongodb/mongodb-drupal.jpg differ diff --git a/slides/mongodb/php-connection-string.xml b/slides/mongodb/php-connection-string.xml index fdd06e8..9b3cf31 100644 --- a/slides/mongodb/php-connection-string.xml +++ b/slides/mongodb/php-connection-string.xml @@ -4,11 +4,11 @@ <example result="0"><![CDATA[<?php $options = array( 'replicaSet' => 'seta' ); -$m = new Mongo( 'mongodb://localhost:13000', $options ); +$m = new Mongo( 'mongodb://user:password@localhost:13000/demo', $options ); $m = new Mongo( 'mongodb://localhost:13000,localhost:13001', $options ); -$m = new Mongo( 'mongodb://user:password@localhost:13000,localhost:13001/demo', $options ); +$m = new Mongo( 'mongodb://localhost:13000,localhost:13001', $options ); ?>]]></example> <list> diff --git a/slides/mongodb/update.xml b/slides/mongodb/update.xml index 60d051e..ac2290d 100644 --- a/slides/mongodb/update.xml +++ b/slides/mongodb/update.xml @@ -1,7 +1,7 @@ <slide> <title>Updating documents</title> -<example result="0"><![CDATA[<?php +<example result="1"><![CDATA[<?php $m = new Mongo; $c = $m->demo->elephpants; $c->remove();