com presentations: Tweaks made on the train over to Brussels.: mongo-tut-phpbnl13.xml slides/map/import-script-exercise.xml
slides/mongodb/aggregation-example-cuisine.xml slides/mongodb/aggregation-example-cuisine1-match.xml
slides/mongodb/aggregation-example-cuisine2-unwind.xml slides/mongodb/aggregation-example-cuisine3-match.xml
slides/mongodb/aggregation-example-cuisine4-group.xml slides/mongodb/aggregation-example-cuisine5-group-with-sum.xml

From: Date: Thu, 24 Jan 2013 14:39:12 +0000
Subject: com presentations: Tweaks made on the train over to Brussels.: mongo-tut-phpbnl13.xml slides/map/import-script-exercise.xml
slides/mongodb/aggregation-example-cuisine.xml slides/mongodb/aggregation-example-cuisine1-match.xml
slides/mongodb/aggregation-example-cuisine2-unwind.xml slides/mongodb/aggregation-example-cuisine3-match.xml
slides/mongodb/aggregation-example-cuisine4-group.xml slides/mongodb/aggregation-example-cuisine5-group-with-sum.xml
Groups: php.pres 
Request: Send a blank email to pres+get-1864@lists.php.net to get a copy of this message
Commit: d7d3d81229615a9e39737d2885769b8d1cc76797 Author: Derick Rethans <github@derickrethans.nl> Thu, 24 Jan 2013 15:39:12 +0100 Parents: e0a696e6c57e5107238d0e91a7b93ff14c131c0d Branches: master Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=d7d3d81229615a9e39737d2885769b8d1cc76797 Log: Tweaks made on the train over to Brussels. Changed paths: M mongo-tut-phpbnl13.xml M slides/map/import-script-exercise.xml M slides/mongodb/aggregation-example-cuisine.xml A slides/mongodb/aggregation-example-cuisine1-match.xml A slides/mongodb/aggregation-example-cuisine2-unwind.xml A slides/mongodb/aggregation-example-cuisine3-match.xml A slides/mongodb/aggregation-example-cuisine4-group.xml A slides/mongodb/aggregation-example-cuisine5-group-with-sum.xml A slides/mongodb/aggregation-example-cuisine6-sort.xml M slides/mongodb/ex1-foursquare.xml M slides/mongodb/many-to-many2.xml M slides/mongodb/many-to-many3.xml M slides/mongodb/query.xml M slides/mongodb/query2.xml M slides/mongodb/repl-features.xml M slides/mongodb/repl-set1.xml M slides/mongodb/repl-set2.xml M slides/mongodb/repl-set3.xml M slides/mongodb/repl-set5.xml M slides/mongodb/repl-works-failover.xml M templates/default/example.ezt

diff --git a/mongo-tut-phpbnl13.xml b/mongo-tut-phpbnl13.xml index 0c523c6..f975618 100644 --- a/mongo-tut-phpbnl13.xml +++ b/mongo-tut-phpbnl13.xml @@ -15,7 +15,6 @@ <slide>slides/mongodb/half-tutorial-topics.xml</slide> <slide>slides/mongodb/section-intro.xml</slide> -<slide>slides/mongodb/databasefield.xml</slide> <slide>slides/mongodb/collections-documents.xml</slide> <slide>slides/mongodb/document.xml</slide> @@ -64,6 +63,12 @@ <slide>slides/mongodb/commands.xml</slide> <slide>slides/mongodb/commands-aggregation.xml</slide> <slide>slides/mongodb/aggregation-example-cuisine.xml</slide> +<slide>slides/mongodb/aggregation-example-cuisine1-match.xml</slide> +<slide>slides/mongodb/aggregation-example-cuisine2-unwind.xml</slide> +<slide>slides/mongodb/aggregation-example-cuisine3-match.xml</slide> +<slide>slides/mongodb/aggregation-example-cuisine4-group.xml</slide> +<slide>slides/mongodb/aggregation-example-cuisine5-group-with-sum.xml</slide> +<slide>slides/mongodb/aggregation-example-cuisine6-sort.xml</slide> <slide>slides/mongodb/questions.xml</slide> @@ -73,7 +78,6 @@ Common Patterns - RDBMS-normalisation. -<slide>slides/mongodb/normalisation.xml</slide> <slide>slides/mongodb/blog.xml</slide> <slide>slides/mongodb/blog2.xml</slide> @@ -83,9 +87,7 @@ Common Patterns <slide>slides/mongodb/one-to-many1.xml</slide> <slide>slides/mongodb/one-to-many2.xml</slide> <slide>slides/mongodb/tip-array-key.xml</slide> -<slide>slides/mongodb/one-to-many3.xml</slide> <slide>slides/mongodb/one-to-many4.xml</slide> -<slide>slides/mongodb/tip-paged-result.xml</slide> <slide>slides/mongodb/many-to-many1.xml</slide> <slide>slides/mongodb/many-to-many2.xml</slide> @@ -99,12 +101,10 @@ Common Patterns <!-- INDEXES --> <slide>slides/mongodb/section-indexes.xml</slide> -<slide>slides/mongodb/idx-whats-in-store.xml</slide> <slide>slides/mongodb/idx-startup-quotes.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-create-php.xml</slide> <slide>slides/mongodb/idx-cities-by-name.xml</slide> <slide>slides/mongodb/idx-how-do-you-find-a-large-city.xml</slide> @@ -115,7 +115,6 @@ Common Patterns <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-stored2.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> @@ -123,18 +122,11 @@ Common Patterns <slide>slides/mongodb/idx-recap1.xml</slide> <slide>slides/mongodb/idx-recap2.xml</slide> - -<slide>slides/mongodb/idx-unique.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-geo3.xml</slide> -<slide>slides/mongodb/idx-geo4.xml</slide> unique sparse @@ -148,7 +140,7 @@ multikey <!-- REPLICATION --> <slide>slides/mongodb/section-replication.xml</slide> <slide>slides/mongodb/repl-use-cases.xml</slide> -<slide>slides/mongodb/repl-types-of-outage.xml</slide> +<!-- <slide>slides/mongodb/repl-types-of-outage.xml</slide> --> <slide>slides/mongodb/repl-features.xml</slide> <slide>slides/mongodb/repl-works-basic.xml</slide> <slide>slides/mongodb/repl-works-normal.xml</slide> @@ -157,12 +149,8 @@ multikey <slide>slides/mongodb/replication-setup.xml</slide> -<slide>slides/mongodb/repl-managing.xml</slide> <slide>slides/mongodb/safe3.xml</slide> <slide>slides/mongodb/repl-write-concern.xml</slide> -<slide>slides/mongodb/repl-tagging.xml</slide> -<slide>slides/mongodb/repl-tagging2.xml</slide> -<slide>slides/mongodb/repl-tagging-example.xml</slide> <slide>slides/mongodb/read-preference2.xml</slide> <slide>slides/mongodb/read-preference.xml</slide> <slide>slides/mongodb/repl-eventual-consistency.xml</slide> @@ -172,7 +160,6 @@ multikey <slide>slides/mongodb/repl-set1.xml</slide> <slide>slides/mongodb/repl-set2.xml</slide> <slide>slides/mongodb/repl-set3.xml</slide> -<slide>slides/mongodb/repl-set4.xml</slide> <slide>slides/mongodb/repl-set5.xml</slide> <slide>slides/mongodb/repl-typical.xml</slide> diff --git a/slides/map/import-script-exercise.xml b/slides/map/import-script-exercise.xml index 4817d21..a226a72 100644 --- a/slides/map/import-script-exercise.xml +++ b/slides/map/import-script-exercise.xml @@ -9,6 +9,7 @@ <bullet>Cast all values, due to SimpleXML weirdness</bullet> <bullet>%_id% needs to be "n" + the node's ID (in %$node['id']%)</bullet> + <bullet>%type% is %1% for nodes</bullet> <bullet>Make sure to add the location (*lon*, *lat*) as a two element array in the %loc% element.</bullet> </list> @@ -17,6 +18,7 @@ <list> <bullet>%_id% needs to be "w" + the node's ID (in %$way['id']%)</bullet> + <bullet>%type% is %2% for ways</bullet> </list> </bullet> <bullet>Add the %insert% statement at #2 and #4</bullet> diff --git a/slides/mongodb/aggregation-example-cuisine.xml b/slides/mongodb/aggregation-example-cuisine.xml index 24ec818..69d0ce8 100644 --- a/slides/mongodb/aggregation-example-cuisine.xml +++ b/slides/mongodb/aggregation-example-cuisine.xml @@ -1,58 +1,25 @@ <slide> <title>Aggregation example</title> -<div effect="fade-out"> + <example> -> db.cities.find({ name: 'Atlanta' }).pretty(); +… { - "_id" : ObjectId("4fe82d3044670a8156004ca0"), - "geonameid" : 4180439, - "name" : "Atlanta", - "asciiname" : "Atlanta", - "alternatenames" : [ - "ATL", "Atlanta", "Atlantae", "aeteullaenta", "arrlanra nagaram", - "atalanta", "atlanta", "atlanta", " jwrjya", "atoranta", "etalanta", - "etlanta", "ya te lan da", "Ατλάντα", "Атлантæ", "Атланта", "Ատլանտա", - "แอตแลนตา", "ཨ་ཊི་ལཱན་ཊཱ།", "အတ္တလန္တာမြို့", "ატლანტა", "アトランタ", - "亚特兰大", "애틀랜타" - ], - "feature_class" : "P", - "feature_code" : "PPLA", - "country_code" : "US", - "admin1_code" : "GA", - "admin2_code" : "121", - "population" : 420003, - "elevation" : 320, - "dem" : 336, - "timezone" : "America/New_York", - "modification_date" : "2011-06-16", - "location" : [ -84.38798, 33.749 ] + "_id" : "n1996641853", + "tags" : [ + "amenity=restaurant", + "cuisine=japanese", + "name=Kaiseki" + ] } +{ + "_id" : "n1618702957", + "tags" : [ + "amenity=fast_food", + "cuisine=kebab", + "name=Pita Durum" + ] +} +… </example> -</div> - -<div effect="fade-in"> -<example result="1"><![CDATA[<?php -$m = new MongoClient(); -$c = $m->demo->cities; - -$res = $c->aggregate( [ - [ '$match' => [ 'name' => 'Atlanta' ] ], - [ '$unwind' => '$alternatenames' ], - [ '$project' => [ - 'name' => '$alternatenames', - 'meta' => [ - 'elevation' => '$dem', - 'population' => 1, - 'timezone' => 1, - ], - 'location' => 1, - '_id' => 0, - ] ], - [ '$sort' => [ 'name' => 1 ] ] -] ); - -var_dump( $res ); -?>]]> -</example> -</div> +<blurb>We want all different cuisines, with their usage count</blurb> </slide> diff --git a/slides/mongodb/aggregation-example-cuisine1-match.xml b/slides/mongodb/aggregation-example-cuisine1-match.xml new file mode 100644 index 0000000..62a4a37 --- /dev/null +++ b/slides/mongodb/aggregation-example-cuisine1-match.xml @@ -0,0 +1,15 @@ +<slide> +<title>Aggregation example</title> + +<example result="3"><![CDATA[<?php +$m = new MongoClient(); + +$res = $m->demo->poi->aggregate( [ + /* First we match all documents that have a cuisine tag: */ + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], +] ); + +var_dump( $res['result'] ); +?>]]> +</example> +</slide> diff --git a/slides/mongodb/aggregation-example-cuisine2-unwind.xml b/slides/mongodb/aggregation-example-cuisine2-unwind.xml new file mode 100644 index 0000000..73a3c96 --- /dev/null +++ b/slides/mongodb/aggregation-example-cuisine2-unwind.xml @@ -0,0 +1,16 @@ +<slide> +<title>Aggregation example</title> + +<example result="3"><![CDATA[<?php +$m = new MongoClient(); + +$res = $m->demo->poi->aggregate( [ + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + /* Then we unwind all the tags */ + [ '$unwind' => '$tags' ], +] ); + +var_dump( $res['result'] ); +?>]]> +</example> +</slide> diff --git a/slides/mongodb/aggregation-example-cuisine3-match.xml b/slides/mongodb/aggregation-example-cuisine3-match.xml new file mode 100644 index 0000000..462e7b7 --- /dev/null +++ b/slides/mongodb/aggregation-example-cuisine3-match.xml @@ -0,0 +1,17 @@ +<slide> +<title>Aggregation example</title> + +<example result="3"><![CDATA[<?php +$m = new MongoClient(); + +$res = $m->demo->poi->aggregate( [ + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + [ '$unwind' => '$tags' ], + /* Match again to get rid of all the useless tags */ + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], +] ); + +var_dump( $res['result'] ); +?>]]> +</example> +</slide> diff --git a/slides/mongodb/aggregation-example-cuisine4-group.xml b/slides/mongodb/aggregation-example-cuisine4-group.xml new file mode 100644 index 0000000..545d3ec --- /dev/null +++ b/slides/mongodb/aggregation-example-cuisine4-group.xml @@ -0,0 +1,18 @@ +<slide> +<title>Aggregation example</title> + +<example result="3"><![CDATA[<?php +$m = new MongoClient(); + +$res = $m->demo->poi->aggregate( [ + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + [ '$unwind' => '$tags' ], + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + /* Now we group on the tags */ + [ '$group' => [ '_id' => '$tags' ] ], +] ); + +var_dump( $res['result'] ); +?>]]> +</example> +</slide> diff --git a/slides/mongodb/aggregation-example-cuisine5-group-with-sum.xml b/slides/mongodb/aggregation-example-cuisine5-group-with-sum.xml new file mode 100644 index 0000000..78bc7b6 --- /dev/null +++ b/slides/mongodb/aggregation-example-cuisine5-group-with-sum.xml @@ -0,0 +1,18 @@ +<slide> +<title>Aggregation example</title> + +<example result="3"><![CDATA[<?php +$m = new MongoClient(); + +$res = $m->demo->poi->aggregate( [ + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + [ '$unwind' => '$tags' ], + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + /* Now we group on the tags, and add the count */ + [ '$group' => [ '_id' => '$tags', 'count' => [ '$sum' => 1 ] ] ], +] ); + +var_dump( $res['result'] ); +?>]]> +</example> +</slide> diff --git a/slides/mongodb/aggregation-example-cuisine6-sort.xml b/slides/mongodb/aggregation-example-cuisine6-sort.xml new file mode 100644 index 0000000..d481859 --- /dev/null +++ b/slides/mongodb/aggregation-example-cuisine6-sort.xml @@ -0,0 +1,19 @@ +<slide> +<title>Aggregation example</title> + +<example result="3"><![CDATA[<?php +$m = new MongoClient(); + +$res = $m->demo->poi->aggregate( [ + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + [ '$unwind' => '$tags' ], + [ '$match' => [ 'tags' => new MongoRegex( '/^cuisine=/' ) ] ], + [ '$group' => [ '_id' => '$tags', 'count' => [ '$sum' => 1 ] ] ], + /* and at last we sort by count */ + [ '$sort' => [ 'count' => -1 ] ], +] ); + +var_dump( $res['result'] ); +?>]]> +</example> +</slide> diff --git a/slides/mongodb/ex1-foursquare.xml b/slides/mongodb/ex1-foursquare.xml index 15adfb6..ac3f038 100644 --- a/slides/mongodb/ex1-foursquare.xml +++ b/slides/mongodb/ex1-foursquare.xml @@ -1,5 +1,5 @@ <slide> -<title>Exercise #1</title> +<title>Exercises — A useful foursquare</title> <blurb class="big-centre">foursquare</blurb> diff --git a/slides/mongodb/many-to-many2.xml b/slides/mongodb/many-to-many2.xml index a1e2f48..f0ddb40 100644 --- a/slides/mongodb/many-to-many2.xml +++ b/slides/mongodb/many-to-many2.xml @@ -7,6 +7,7 @@ categories: { _id: 4, name: "toys", product_ids: [ 10, 11 ] } +{ _id: 7, name: "everything blue", product_ids: [ 10 ] } { _id: 8, name: "everything pink", product_ids: [ 11 ] }]]></example> <blurb>All categories for a given product (pink elephpant):</blurb> diff --git a/slides/mongodb/many-to-many3.xml b/slides/mongodb/many-to-many3.xml index 4c4b7fd..9c3a68d 100644 --- a/slides/mongodb/many-to-many3.xml +++ b/slides/mongodb/many-to-many3.xml @@ -7,6 +7,7 @@ categories: { _id: 4, name: "toys" } +{ _id: 7, name: "everything blue"} { _id: 8, name: "everything pink"}]]></example> <blurb>All categories for a given product (pink elephpant):</blurb> diff --git a/slides/mongodb/query.xml b/slides/mongodb/query.xml index 3b6dc89..280e6ee 100644 --- a/slides/mongodb/query.xml +++ b/slides/mongodb/query.xml @@ -1,5 +1,5 @@ <slide> -<title>Querying (1)</title> +<title>Querying (one document)</title> <example><![CDATA[<?php $m = new MongoClient(); diff --git a/slides/mongodb/query2.xml b/slides/mongodb/query2.xml index a07d0be..2eaf402 100644 --- a/slides/mongodb/query2.xml +++ b/slides/mongodb/query2.xml @@ -1,5 +1,5 @@ <slide> -<title>Querying (2)</title> +<title>Querying (with projection)</title> <example result="0"><![CDATA[<?php $m = new MongoClient(); diff --git a/slides/mongodb/repl-features.xml b/slides/mongodb/repl-features.xml index 1171bef..966788c 100644 --- a/slides/mongodb/repl-features.xml +++ b/slides/mongodb/repl-features.xml @@ -4,7 +4,7 @@ <list> <bullet>A cluster of N servers</bullet> <bullet>All writes to primary</bullet> - <bullet>Reads can be to primary (default) or a secondary</bullet> + <bullet>Reads can be from primary (default) or a secondary</bullet> <bullet>Any (one) node can be primary</bullet> <bullet>Consensus election of primary</bullet> <bullet>Automatic failover</bullet> diff --git a/slides/mongodb/repl-set1.xml b/slides/mongodb/repl-set1.xml index a210932..fcce65b 100644 --- a/slides/mongodb/repl-set1.xml +++ b/slides/mongodb/repl-set1.xml @@ -1,5 +1,5 @@ <slide> -<title>Replicaset 1</title> +<title>Replicaset (single dc)</title> <image filename="repl-set2.png"/> diff --git a/slides/mongodb/repl-set2.xml b/slides/mongodb/repl-set2.xml index 576e5c4..750fe49 100644 --- a/slides/mongodb/repl-set2.xml +++ b/slides/mongodb/repl-set2.xml @@ -1,5 +1,5 @@ <slide> -<title>Replicaset 2</title> +<title>Replicaset (multiple zones, with arbiter)</title> <image filename="repl-set3.png"/> diff --git a/slides/mongodb/repl-set3.xml b/slides/mongodb/repl-set3.xml index 51398cb..2d83302 100644 --- a/slides/mongodb/repl-set3.xml +++ b/slides/mongodb/repl-set3.xml @@ -1,5 +1,5 @@ <slide> -<title>Replicaset 3</title> +<title>Replicaset (multiple zones)</title> <image filename="repl-set4.png"/> diff --git a/slides/mongodb/repl-set5.xml b/slides/mongodb/repl-set5.xml index f801395..1d45032 100644 --- a/slides/mongodb/repl-set5.xml +++ b/slides/mongodb/repl-set5.xml @@ -1,5 +1,5 @@ <slide> -<title>Replicaset 5</title> +<title>Replicaset (fully redundant)</title> <image filename="repl-set6.png"/> diff --git a/slides/mongodb/repl-works-failover.xml b/slides/mongodb/repl-works-failover.xml index 716e4da..d6b5781 100644 --- a/slides/mongodb/repl-works-failover.xml +++ b/slides/mongodb/repl-works-failover.xml @@ -6,7 +6,7 @@ <image filename="repl-set-down.png"/> <list> - <bullet>PRIMARY mail fail</bullet> + <bullet>PRIMARY may fail</bullet> <bullet>Automatic election of new PRIMARY if majority exists</bullet> </list> </div> diff --git a/templates/default/example.ezt b/templates/default/example.ezt index 993dedc..e30c75f 100644 --- a/templates/default/example.ezt +++ b/templates/default/example.ezt @@ -15,4 +15,10 @@ </div> </div> {/if} + {if get_attribute( $node, 'result' ) == 3 && $result != ""} +<div class='result'> +<p>Result:</p> +<pre>{raw $result}</pre> +</div> + {/if} {/if}
« previous php.pres (#1864) next »