com presentations: Nomad PHP talk: mongo-nomad16.xml slides/mongodb/agenda-grownup.xml slides/mongodb/indexes-explain-index-sort.xml slides/mongodb/indexes-explain-noindex.xml slides/mongodb/indexes-explain-sort-backwards.xml slides/mongodb/indexes-new.xml slides/mongodb/indexes-php.xml slides/mongodb/recap-grownup.xml slides/mongodb/text-create-index-php.xml slides/mongodb/text-index-options.xml slides/mongodb/text-query-options.xml slides/mongo

[email protected] (Derick Rethans) Thu, 28 Jul 2016 17:34:39 +0000
Newsgroups php.pres
Message-ID <[email protected]>
Commit:    4d3d7fc7c96f0c1e4f3266c5dc756cbb8d56d8ff
Author:    Derick Rethans <[email protected]>         Thu, 28 Jul 2016 18:34:39 +0100
Parents:   8590e339a63ccf4696fc60e7cad236273916da27
Branches:  master

Link:       http://git.php.net/?p=presentations.git;a=commitdiff;h=4d3d7fc7c96f0c1e4f3266c5dc756cbb8d56d8ff

Log:
Nomad PHP talk

Changed paths:
  A  mongo-nomad16.xml
  A  slides/mongodb/agenda-grownup.xml
  A  slides/mongodb/indexes-explain-index-sort.xml
  A  slides/mongodb/indexes-explain-noindex.xml
  A  slides/mongodb/indexes-explain-sort-backwards.xml
  M  slides/mongodb/indexes-new.xml
  M  slides/mongodb/indexes-php.xml
  A  slides/mongodb/recap-grownup.xml
  M  slides/mongodb/text-create-index-php.xml
  M  slides/mongodb/text-index-options.xml
  M  slides/mongodb/text-query-options.xml
  M  slides/mongodb/text-run-command.xml
diff_4d3d7fc7c96f0c1e4f3266c5dc756cbb8d56d8ff.txt (text/plain, 12.5 KB)
diff --git a/mongo-nomad16.xml b/mongo-nomad16.xml
new file mode 100644
index 0000000..c6c8138
--- /dev/null
+++ b/mongo-nomad16.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<presentation css="10gen-strict.css">
+<topic>MongoDB</topic>
+<title>Grown-up MongoDB: Schema Design</title>
+<event>Nomad PHP</event>
+<location>Online</location>
+<date>Jul 28th, 2016</date>
+<speaker>Derick Rethans</speaker>
+<email>[email protected]</email>
+<twitter>derickr</twitter>
+<url>http://derickrethans.nl/talks.html</url>
+<joindin>https://joind.in/talk/cad90</joindin>
+<slide>slides/mongodb/title.xml</slide>
+<slide>slides/mongodb/me.xml</slide>
+
+<slide>slides/mongodb/agenda-grownup.xml</slide>
+
+** Terms **
+
+<slide>slides/mongodb/collections-documents.xml</slide>
+
+<slide>slides/mongodb/document-title.xml</slide>
+<slide>slides/mongodb/document-simple.xml</slide>
+<slide>slides/mongodb/document-complex.xml</slide>
+
+<slide>slides/mongodb/collections-title.xml</slide>
+<slide>slides/mongodb/collections.xml</slide>
+
+<slide>slides/mongodb/index-title.xml</slide>
+<slide>slides/mongodb/index.xml</slide>
+
+** From PHP **
+
+<slide>slides/mongodb/phplib-title.xml</slide>
+<slide>slides/mongodb/phplib-intro.xml</slide>
+<slide>slides/mongodb/phplib-crud.xml</slide>
+<slide>slides/mongodb/phplib-index.xml</slide>
+
+<slide>slides/mongodb/keys-title.xml</slide>
+<slide>slides/mongodb/data-model.xml</slide>
+
+Common Patterns
+
+- RDBMS-normalisation.
+
+<slide>slides/mongodb/eav.xml</slide>
+<slide>slides/mongodb/eav2.xml</slide>
+<slide>slides/mongodb/eav3.xml</slide>
+
+<slide>slides/mongodb/dram-erd.xml</slide>
+<slide>slides/mongodb/dram-erd-in-mongo.xml</slide>
+<slide>slides/mongodb/whisky-words.xml</slide>
+<slide>slides/mongodb/whisky-checking.xml</slide>
+
+<slide>slides/mongodb/clinks.xml</slide>
+<slide>slides/mongodb/clinks1.xml</slide>
+<slide>slides/mongodb/clinks2.xml</slide>
+<slide>slides/mongodb/clinks3.xml</slide>
+<slide>slides/mongodb/clinks4.xml</slide>
+<slide>slides/mongodb/clinks5.xml</slide>
+
+<slide>slides/mongodb/document-validation.xml</slide>
+
+<slide>slides/mongodb/embed-vs-link.xml</slide>
+
+<slide>slides/mongodb/index-title.xml</slide>
+<slide>slides/mongodb/indexes-new.xml</slide>
+<slide>slides/mongodb/indexes-php.xml</slide>
+
+<slide>slides/mongodb/indexes-explain-noindex.xml</slide>
+
+<slide>slides/mongodb/indexes-explain2.xml</slide>
+<slide>slides/mongodb/indexes-explain-index-sort.xml</slide>
+<slide>slides/mongodb/indexes-explain3.xml</slide>
+
+<slide>slides/mongodb/indexes-special.xml</slide>
+
+<!-- MongoDB text search -->
+<slide>slides/mongodb/text-create-index-php.xml</slide>
+<slide>slides/mongodb/text-run-command.xml</slide>
+<slide>slides/mongodb/text-index-options.xml</slide>
+<slide>slides/mongodb/text-query-syntax.xml</slide>
+
+<slide>slides/mongodb/recap-grownup.xml</slide>
+
+<slide>slides/mongodb/questions.xml</slide>
+<slide>slides/mongodb/mongodbeurope16.xml</slide>
+<slide>slides/mongodb/resources.xml</slide>
+
+</presentation>
diff --git a/slides/mongodb/agenda-grownup.xml b/slides/mongodb/agenda-grownup.xml
new file mode 100644
index 0000000..b66e9ae
--- /dev/null
+++ b/slides/mongodb/agenda-grownup.xml
@@ -0,0 +1,10 @@
+<slide>
+<title>Agenda</title>
+
+<list>
+	<bullet>Introduction</bullet>
+	<bullet>PHP &amp; MongoDB</bullet>
+	<bullet>Data Model</bullet>
+	<bullet>Indexes</bullet>
+</list>
+</slide>
diff --git a/slides/mongodb/indexes-explain-index-sort.xml b/slides/mongodb/indexes-explain-index-sort.xml
new file mode 100644
index 0000000..28917b6
--- /dev/null
+++ b/slides/mongodb/indexes-explain-index-sort.xml
@@ -0,0 +1,31 @@
+<slide>
+<title>Explain (Sort)</title>
+
+<example inline="1"><![CDATA[
+> db.whisky.find( { name: 'Ord 10' } ).sort( *{ name: -1 }* ).explain();
+{
+    "queryPlanner" : {
+        "namespace" : "dramio.whisky",
+        "indexFilterSet" : false,
+        "parsedQuery" : { "name" : { "$eq" : "Ord 10" } },
+        "winningPlan" : {
+            "stage" : "FETCH",
+            "inputStage" : {
+                "stage" : "IXSCAN",
+                "keyPattern" : {
+                    "name" : 1
+                },
+                "indexName" : "name_1",
+                "isMultiKey" : false,
+                "direction" : *"backward"*,
+                "indexBounds" : {
+                    "name" : [
+                        "[\"Ord 10\", \"Ord 10\"]"
+                    ]
+                }
+            }
+        },
+    },
+}
+]]></example>
+</slide>
diff --git a/slides/mongodb/indexes-explain-noindex.xml b/slides/mongodb/indexes-explain-noindex.xml
new file mode 100644
index 0000000..6dc1210
--- /dev/null
+++ b/slides/mongodb/indexes-explain-noindex.xml
@@ -0,0 +1,24 @@
+<slide>
+<title>Explain (No Index)</title>
+
+<example inline="1"><![CDATA[
+> db.whisky.find( { distillery: 'Ord' } ).explain();
+{
+    "queryPlanner" : {
+        "namespace" : *"dramio.whisky",*
+        "indexFilterSet" : false,
+        "parsedQuery" : { "distillery" : { "$eq" : "Ord" } },
+        "winningPlan" : {
+            "stage" : *"COLLSCAN",*
+            "filter" : {
+                "distillery" : {
+                    *"$eq" : "Ord"*
+                }
+            },
+            "direction" : "forward"
+        },
+        *"rejectedPlans" : [ ]*
+    },
+}
+]]></example>
+</slide>
diff --git a/slides/mongodb/indexes-explain-sort-backwards.xml b/slides/mongodb/indexes-explain-sort-backwards.xml
new file mode 100644
index 0000000..ca795fc
--- /dev/null
+++ b/slides/mongodb/indexes-explain-sort-backwards.xml
@@ -0,0 +1,32 @@
+<slide>
+<title>Explain (Covering Index)</title>
+
+<example inline="1"><![CDATA[
+> db.whisky.find( { name: 'Ord 10' }, { _id: 0, name: 1 } ).sort( { name: -1 } ).explain();
+{
+    "queryPlanner" : {
+        "namespace" : "dramio.whisky",
+        "indexFilterSet" : false,
+        "parsedQuery" : { "name" : { "$eq" : "Ord 10" } },
+        "winningPlan" : {
+            *"stage" : "PROJECTION",*
+            "transformBy" : *{ "_id" : 0, "name" : 1 }*,
+            "inputStage" : {
+                *"stage" : "IXSCAN",*
+                "keyPattern" : {
+                    "name" : 1
+                },
+                "indexName" : "name_1",
+                "isMultiKey" : false,
+                "direction" : "forward",
+                "indexBounds" : {
+                    "name" : [
+                        "[\"Ord 10\", \"Ord 10\"]"
+                    ]
+                }
+            }
+        },
+    },
+}
+]]></example>
+</slide>
diff --git a/slides/mongodb/indexes-new.xml b/slides/mongodb/indexes-new.xml
index 82f4c9c..e39ad74 100644
--- a/slides/mongodb/indexes-new.xml
+++ b/slides/mongodb/indexes-new.xml
@@ -8,7 +8,7 @@
 	<bullet>Indexes are just as important as in a relational database</bullet>
 	<bullet>Every collection has (automatically) an index on %_id%</bullet>
 	<bullet>Indexes can be: single field, compound key, on nested field names</bullet>
-	<bullet>MongoCursor->explain().</bullet>
+	<bullet>Indexes do add overhead</bullet>
 </list>
 </div>
 </slide>
diff --git a/slides/mongodb/indexes-php.xml b/slides/mongodb/indexes-php.xml
index 6966cf1..9d1af04 100644
--- a/slides/mongodb/indexes-php.xml
+++ b/slides/mongodb/indexes-php.xml
@@ -7,18 +7,18 @@ db.checkins.createIndex( { 'clinked_by.slug': 1 } );
 </example>
 
 <blurb>Driver</blurb>
-<example inline="1"><![CDATA[
+<example inline="1"><![CDATA[&lt;?php
 $cmd = new \MongoDB\Driver\Command( [
     'createIndexes => 'checkins',
     'indexes' => [
         [ *'key'* => [ 'user_slug' => 1, 'friend_slug => 1 ], *'unique'* => true ],
     ]
 ] );
-$manager->executeCommand( $cmd );
+$manager->executeCommand( 'dramio', $cmd );
 ]]></example>
 
 <blurb>Library</blurb>
-<example inline="1"><![CDATA[
+<example inline="1"><![CDATA[&lt;?php
 require 'vendor/autoload.php';
 $collection = (new MongoDB\Client)->dramio->user;
 $collection->createIndex(
diff --git a/slides/mongodb/recap-grownup.xml b/slides/mongodb/recap-grownup.xml
new file mode 100644
index 0000000..afbe4dc
--- /dev/null
+++ b/slides/mongodb/recap-grownup.xml
@@ -0,0 +1,10 @@
+<slide>
+<title>Recap</title>
+
+<list>
+	<bullet>Introduction</bullet>
+	<bullet>PHP &amp; MongoDB</bullet>
+	<bullet>Data Model</bullet>
+	<bullet>Indexes</bullet>
+</list>
+</slide>
diff --git a/slides/mongodb/text-create-index-php.xml b/slides/mongodb/text-create-index-php.xml
index 3228e33..8020692 100644
--- a/slides/mongodb/text-create-index-php.xml
+++ b/slides/mongodb/text-create-index-php.xml
@@ -1,12 +1,27 @@
 <slide>
 <title>Create a Text Search Index</title>
 
-<example><![CDATA[<?php
-$m = new MongoClient;
+<blurb>Driver</blurb>
+<example inline="1"><![CDATA[&lt;?php
+$cmd = new \MongoDB\Driver\Command( [
+    'createIndexes => 'articles',
+    'indexes' => [
+        [
+          'key' => [ 'subject' => *'text'*, 'post' => *'text'* ],
+          *'weights' => [ 'subject' => 10, 'post' => 5 ]*
+        ]
+    ]
+] );
+$manager->executeCommand( 'demo', $cmd );
+?>]]></example>
 
-$m->demo->articles->createIndex(
-	[ 'subject' => 'text', 'post' => 'text' ],
-	[ 'weights' => [ 'subject' => 10, 'post' => 5 ] ]
+<blurb>Library</blurb>
+<example inline="1"><![CDATA[&lt;?php
+require 'vendor/autoload.php';
+$collection = (new MongoDB\Client)->demo->articles;
+$collection->createIndex(
+    [ 'subject' => *'text'*, 'post' => *'text'* ],
+    [ *'weights' => [ 'subject' => 10, 'post' => 5 ]* ]
 );
 ?>]]></example>
 </slide>
diff --git a/slides/mongodb/text-index-options.xml b/slides/mongodb/text-index-options.xml
index b94ccef..a9ce6d5 100644
--- a/slides/mongodb/text-index-options.xml
+++ b/slides/mongodb/text-index-options.xml
@@ -4,30 +4,34 @@
 <blurb>
 Basic, default weights:
 </blurb>
-<example>
-db.articles.createIndex( { subject: "text", post: "text" } );
+<example inline="1">
+$collection->createIndex( [ 'subject' => *'text'*, 'post' => *'text'* ] ),
 </example>
 
 <blurb>
 Explicit weights:
 </blurb>
-<example>
-db.articles.createIndex( { subject: "text", post: "text" },
-                         { weights: { "subject": 10 } } );
+<example inline="1">
+$collection->createIndex(
+    [ 'subject' => 'text', 'post' => 'text' ],
+    [ *'weights' => [ 'subject' => 10 ]* ]
+);
 </example>
 
 <blurb>
 Wildcard field: text at any depth, default weights:
 </blurb>
-<example>
-db.articles.createIndex( { "$**": "text" } );
+<example inline="1">
+$collection->createIndex( [ *'$\*\*'* => 'text' ] ),
 </example>
 
 <blurb>
-Wildcard field: override default weights and explicit weights:
+Wildcard: override default weights and explicit weights:
 </blurb>
-<example>
-db.articles.createIndex( { "$**": "text" },
-                         { weights: {"$**": 10, post: 5 } } );
+<example inline="1">
+$collection->createIndex(
+    [ '$\*\*' => 'text' ],
+    [ *'weights' => [ '$\*\*' => 10, 'post' => 5 ]* ]
+);
 </example>
 </slide>
diff --git a/slides/mongodb/text-query-options.xml b/slides/mongodb/text-query-options.xml
index a9a18cf..b66725d 100644
--- a/slides/mongodb/text-query-options.xml
+++ b/slides/mongodb/text-query-options.xml
@@ -1,7 +1,7 @@
 <slide>
 <title>Query Options and Sorting</title>
 
-<example result="1"><![CDATA[<?php
+<example result="0"><![CDATA[<?php
 $m = new MongoClient;
 
 $cursor = $m->demo->articles->find(
diff --git a/slides/mongodb/text-run-command.xml b/slides/mongodb/text-run-command.xml
index c582c3a..54e7c6b 100644
--- a/slides/mongodb/text-run-command.xml
+++ b/slides/mongodb/text-run-command.xml
@@ -1,25 +1,34 @@
 <slide>
 <title>Do a Text Search Query</title>
 
-<div effect="fade-out">
-<example>
-db.articles.find(
-	{ '$text' : { '$search' : '"advent" "xdebug"' } },
-	{ subject: 1, _id: 0 }
-);
-</example>
-</div>
+<example inline="1"><![CDATA[&lt;?php
+require 'vendor/autoload.php';
+$m = new \MongoDB\Client;
 
-<div effect="fade-in">
-<example result="1"><![CDATA[<?php
-$m = new MongoClient;
 $cursor = $m->demo->articles->find(
-	[ '$text' => [ '$search' => '"advent" "xdebug"' ] ],
+	[ *'$text'* => [ '$search' => '"advent" "xdebug"' ] ],
 	[ 'subject' => 1, '_id' => 0 ]
 );
 foreach ( $cursor as $result ) {
 	echo $result['subject'], "\n";
 }
 ?>]]></example>
+
+<div effect="fade-in">
+<blurb>Result:</blurb>
+<example>
+Contributing Advent 17: Printing stacks
+Contributing Advent 22: Documenting changes
+Contributing Advent 20: Xdebug halting on error
+Contributing Advent 8: The magic __FILE__ constant
+Contributing Advent 23: Reproducing issues
+Whisky Advent: part 3
+Whisky Advent: part 4
+Contributing Advent 1: Xdebug and hidden properties
+Contributing Advent 24: Wrapping up!
+Contributing Advent
+Contributing Advent 15: Xdebug connection timeout
+</example>
 </div>
+
 </slide>