com presentations: Updates from first run through with Jeremy: mongo-tut-tek15.xml slides/mongodb/blog.xml slides/mongodb/blog2.xml slides/mongodb/collections-documents.xml slides/mongodb/commands.xml slides/mongodb/connecting.xml slides/mongodb/considerations.xml slides/mongodb/excercise-finding-data.xml slides/mongodb/excercise-import-untappd.xml slides/mongodb/excercise-import-with-types.xml slides/mongodb/excercise.xml slides/mongodb/excercis
[email protected] (Derick Rethans)
| Newsgroups | php.pres |
|---|---|
| Message-ID | <[email protected]> |
Commit: 42bccf0fb9a6120c971280bc3575e85929758d33 Author: Derick Rethans <[email protected]> Thu, 14 May 2015 08:17:38 +0100 Parents: cd91fae13a17ae5be28d91c9c8165652d4ec1866 Branches: master Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=42bccf0fb9a6120c971280bc3575e85929758d33 Log: Updates from first run through with Jeremy Changed paths: M mongo-tut-tek15.xml M slides/mongodb/blog.xml M slides/mongodb/blog2.xml M slides/mongodb/collections-documents.xml M slides/mongodb/commands.xml M slides/mongodb/connecting.xml M slides/mongodb/considerations.xml M slides/mongodb/excercise-finding-data.xml M slides/mongodb/excercise-import-untappd.xml M slides/mongodb/excercise-import-with-types.xml M slides/mongodb/excercise.xml M slides/mongodb/excercise02-distillers-storage.xml M slides/mongodb/excercise03-add-like.xml M slides/mongodb/excercise03-push-to-add-review.xml M slides/mongodb/excercise03-reviews-example.xml M slides/mongodb/excercise03-reviews.xml M slides/mongodb/half-tutorial-topics.xml M slides/mongodb/one-to-many1.xml M slides/mongodb/one-to-many2.xml M slides/mongodb/one-to-many4.xml M slides/mongodb/query-advanced-ops.xml M slides/mongodb/query.xml M slides/mongodb/query2.xml M slides/mongodb/tip-array-key.xml M slides/mongodb/types-php.xml M slides/mongodb/types.xml M slides/mongodb/update2a.xml
diff_42bccf0fb9a6120c971280bc3575e85929758d33.txt
(text/plain, 18.1 KB)
diff --git a/mongo-tut-tek15.xml b/mongo-tut-tek15.xml index 656b288..34ea60f 100644 --- a/mongo-tut-tek15.xml +++ b/mongo-tut-tek15.xml @@ -6,8 +6,8 @@ <location>Rosemont, IL, US</location> <date>May 18th, 2015</date> <speaker>Derick Rethans & Jeremy Mikola</speaker> -<email>[email protected]</email> -<twitter>derickr</twitter> +<email>[email protected] & [email protected]</email> +<twitter>derickr & @jmikola</twitter> <url>http://derickrethans.nl/talks.html</url> <joindin>https://joind.in/13776</joindin> <slide>slides/mongodb/title.xml</slide> @@ -84,8 +84,8 @@ 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-many4.xml</slide> +<slide>slides/mongodb/tip-array-key.xml</slide> <!-- SECOND EXCERCISE --> <slide>slides/mongodb/excercise.xml</slide> diff --git a/slides/mongodb/blog.xml b/slides/mongodb/blog.xml index 77f63e2..b01deb0 100644 --- a/slides/mongodb/blog.xml +++ b/slides/mongodb/blog.xml @@ -1,5 +1,5 @@ <slide> -<title>Blog in a RDBMS</title> +<title>Blog in a relational model</title> <image filename="blog1.png"/> </slide> diff --git a/slides/mongodb/blog2.xml b/slides/mongodb/blog2.xml index 4b46062..95445ef 100644 --- a/slides/mongodb/blog2.xml +++ b/slides/mongodb/blog2.xml @@ -1,5 +1,5 @@ <slide> -<title>Blog in MongoDB</title> +<title>Blog in a document model</title> <image filename="blog2.png"/> </slide> diff --git a/slides/mongodb/collections-documents.xml b/slides/mongodb/collections-documents.xml index 3ec1c26..7c0145a 100644 --- a/slides/mongodb/collections-documents.xml +++ b/slides/mongodb/collections-documents.xml @@ -6,5 +6,6 @@ <bullet>*Collection*: contains documents (table, view)</bullet> <bullet>*Index*</bullet> <bullet>*Embedded Document* (~join)</bullet> + <bullet>*Sharding* (partitioning)</bullet> </list> </slide> diff --git a/slides/mongodb/commands.xml b/slides/mongodb/commands.xml index dbf91d0..a98ea41 100644 --- a/slides/mongodb/commands.xml +++ b/slides/mongodb/commands.xml @@ -2,9 +2,10 @@ <title>Commands</title> <list> - <bullet>Are run on the database</bullet> + <bullet>Are run against a database</bullet> <bullet>Some (aggregation) return a cursor</bullet> <bullet>Others return one document</bullet> - <bullet>Some commands have helpers in the drivers and shell, most don't</bullet> + <bullet>Some common commands have helpers in the drivers and shell, most + commands don't have a helper</bullet> </list> </slide> diff --git a/slides/mongodb/connecting.xml b/slides/mongodb/connecting.xml index 4fd45b7..36b780d 100644 --- a/slides/mongodb/connecting.xml +++ b/slides/mongodb/connecting.xml @@ -2,15 +2,15 @@ <title>Connecting to MongoDB</title> <blurb>No databases or collections have to do be explicitly created:</blurb> -<break /> <example><![CDATA[<?php $m = new MongoClient(); -$database = $m->demo; -$collection = $database->testCollection; +$database = $m->selectDB( 'demo' ); +$collection = $database->selectCollection( 'testCollection' ); +// or +$collection = $m->selectCollection( 'demo', 'testCollection' ); ?>]]> </example> -<break/> <blurb>Different connection strings:</blurb> <list> diff --git a/slides/mongodb/considerations.xml b/slides/mongodb/considerations.xml index 1f7087e..1ad3fc0 100644 --- a/slides/mongodb/considerations.xml +++ b/slides/mongodb/considerations.xml @@ -2,16 +2,15 @@ <title>Schema considerations</title> <list> -<blurb>Access Patterns?</blurb> +<blurb>Access Patterns</blurb> <bullet>Read / Write Ratio</bullet> - <bullet>Types of updates</bullet> - <bullet>Types of queries</bullet> + <bullet>Types of queries and updates</bullet> <bullet>Data life-cycle</bullet> </list> <break/> <blurb>Considerations</blurb> <list> - <bullet>No Joins</bullet> - <bullet>Document writes are atomic</bullet> + <bullet>Only single document writes are atomic</bullet> + <bullet>No joins</bullet> </list> </slide> diff --git a/slides/mongodb/excercise-finding-data.xml b/slides/mongodb/excercise-finding-data.xml index 0e031b4..08b5691 100644 --- a/slides/mongodb/excercise-finding-data.xml +++ b/slides/mongodb/excercise-finding-data.xml @@ -1,10 +1,10 @@ <slide> -<title>Excercise: querying</title> +<title>Exercise: querying</title> <div>Write a script that:</div> <list> - <bullet>Outputs the *date* date of the first "check-in" for *USA Hells*</bullet> + <bullet>Outputs the *created at* date of the first "check-in" for *USA Hells*</bullet> <bullet>List all *beer names* (with rating and date), where the beer has a rating of *4.5 or higher*, ordered first by rating (highest first), and second by date (earliest first).</bullet> diff --git a/slides/mongodb/excercise-import-untappd.xml b/slides/mongodb/excercise-import-untappd.xml index 4e973b8..83e9035 100644 --- a/slides/mongodb/excercise-import-untappd.xml +++ b/slides/mongodb/excercise-import-untappd.xml @@ -1,5 +1,5 @@ <slide> -<title>Excercise: Import Beer</title> +<title>Exercise: Import Beer</title> <list> <bullet>%git clone https://github.com/derickr/mongo-tutorial.git%</bullet> @@ -8,8 +8,8 @@ <bullet>Write a script to import each beer into the *tutorial* database and the *beer* collection</bullet> <bullet>Verify the result on the mongo shell: <example> -mongo tutorial -db.beer.count(); +$ mongo tutorial +> db.beer.count(); </example> </bullet> </list> diff --git a/slides/mongodb/excercise-import-with-types.xml b/slides/mongodb/excercise-import-with-types.xml index c339e47..945554c 100644 --- a/slides/mongodb/excercise-import-with-types.xml +++ b/slides/mongodb/excercise-import-with-types.xml @@ -1,5 +1,5 @@ <slide> -<title>Excercise: import with types</title> +<title>Exercise: import with types</title> <div>Update the import script to use types</div> diff --git a/slides/mongodb/excercise.xml b/slides/mongodb/excercise.xml index 9bf7029..070dceb 100644 --- a/slides/mongodb/excercise.xml +++ b/slides/mongodb/excercise.xml @@ -1,3 +1,3 @@ <slide type="section"> -<blurb>Excercise</blurb> +<blurb>Exercise</blurb> </slide> diff --git a/slides/mongodb/excercise02-distillers-storage.xml b/slides/mongodb/excercise02-distillers-storage.xml index fd3120a..8c7cac2 100644 --- a/slides/mongodb/excercise02-distillers-storage.xml +++ b/slides/mongodb/excercise02-distillers-storage.xml @@ -9,7 +9,7 @@ Information to store is: <list> <bullet>Distillery: country, region (optional), name, opening year</bullet> <bullet>Whisky: name, age, strength, vintage (optional)</bullet> - <bullet>The relation between them</bullet> + <bullet>The relationship between them</bullet> </list> </slide> diff --git a/slides/mongodb/excercise03-add-like.xml b/slides/mongodb/excercise03-add-like.xml index 95db0b6..197f16b 100644 --- a/slides/mongodb/excercise03-add-like.xml +++ b/slides/mongodb/excercise03-add-like.xml @@ -6,9 +6,9 @@ notes: [ { user_name: "Derick", - date: 2013-10-02, + date: ISODate("2013-10-02"), note: "Caramel and honey, fruity with some hints of earth", - likes: 17 + likes: 17, rating: 3, } ] @@ -20,7 +20,7 @@ $m = new MongoClient; $c = $m->demo->whisky; $c->update( - array( 'name' => 'Glenfiddich 15', 'user_name' => 'Derick' ), + array( 'name' => 'Glenfiddich 15', 'notes.user_name' => 'Derick' ), array( '$inc => array( 'notes.$.likes' => 1 ) ) ); ?>]]></example> diff --git a/slides/mongodb/excercise03-push-to-add-review.xml b/slides/mongodb/excercise03-push-to-add-review.xml index 3530f99..5995de1 100644 --- a/slides/mongodb/excercise03-push-to-add-review.xml +++ b/slides/mongodb/excercise03-push-to-add-review.xml @@ -6,9 +6,9 @@ notes: [ { user_name: "Derick", - date: 2013-10-02, + date: ISODate("2013-10-02"), note: "Caramel and honey, fruity with some hints of earth", - likes: 17 + likes: 17, rating: 3, } ] @@ -21,7 +21,7 @@ $c = $m->demo->whisky; $newReview = array( user_name => "Michael", - date => 2013-10-01, + date => new MongoDate(strtotime("2013-10-01")), note => "No peat, but fruity", rating => 1, ); diff --git a/slides/mongodb/excercise03-reviews-example.xml b/slides/mongodb/excercise03-reviews-example.xml index ab03899..03767c9 100644 --- a/slides/mongodb/excercise03-reviews-example.xml +++ b/slides/mongodb/excercise03-reviews-example.xml @@ -11,13 +11,13 @@ <blurb>Collection: user</blurb> <example><![CDATA[{ name: "Derick", - country: "England" + country: "England", }]]></example> <blurb>Collection: notes</blurb> <example><![CDATA[{ user_name: "Derick", whisky_name: "Glenfiddich 15", - date: 2013-10-02, + date: ISODate("2013-10-02"), note: "Caramel and honey, fruity with some hints of earth", likes: 17, rating: 3, @@ -27,7 +27,7 @@ <div effect="fade-in-out"> <blurb>Collection: whisky</blurb> <example><![CDATA[{ - name: "Glenfiddch 15", + name: "Glenfiddich 15", age: 15, strength: 50.3, }]]></example> @@ -38,9 +38,9 @@ tasting_notes: [ { whisky_name: "Glenfiddich 15", - date: 2013-10-02, + date: ISODate("2013-10-02"), note: "Caramel and honey, fruity with some hints of earth", - likes: 17 + likes: 17, rating: 3, } ] @@ -50,15 +50,15 @@ <div effect="fade-in"> <blurb>Collection: whisky</blurb> <example><![CDATA[{ - name: "Glenfiddch 15", + name: "Glenfiddich 15", age: 15, strength: 50.3, - notes: [ + tasting_notes: [ { user_name: "Derick", - date: 2013-10-02, + date: ISODate("2013-10-02"), note: "Caramel and honey, fruity with some hints of earth", - likes: 17 + likes: 17, rating: 3, } ] @@ -66,7 +66,7 @@ <blurb>Collection: user</blurb> <example><![CDATA[{ name: "Derick", - country: "England" + country: "England", }]]></example> </div> diff --git a/slides/mongodb/excercise03-reviews.xml b/slides/mongodb/excercise03-reviews.xml index 66b40da..e7d1a3e 100644 --- a/slides/mongodb/excercise03-reviews.xml +++ b/slides/mongodb/excercise03-reviews.xml @@ -1,7 +1,7 @@ <slide> <title>Tasting notes</title> -<blurb>Tasting notes is like "review" of how whisky tastes. Each user +<blurb>Tasting notes are like a review of whiskes. Each user can have a note for each whisky. Design a schema that allows for:</blurb> <list> diff --git a/slides/mongodb/half-tutorial-topics.xml b/slides/mongodb/half-tutorial-topics.xml index eb7f238..1a9a69c 100644 --- a/slides/mongodb/half-tutorial-topics.xml +++ b/slides/mongodb/half-tutorial-topics.xml @@ -7,6 +7,7 @@ <bullet>Schema Design</bullet> <bullet>Indexes</bullet> <bullet>Introduction to Replication</bullet> + <bullet>Introduction to Sharding</bullet> <bullet>Questions and Answers</bullet> </list> </slide> diff --git a/slides/mongodb/one-to-many1.xml b/slides/mongodb/one-to-many1.xml index 908d5f4..5b7fe57 100644 --- a/slides/mongodb/one-to-many1.xml +++ b/slides/mongodb/one-to-many1.xml @@ -3,9 +3,8 @@ <blurb>One to Many relationships can specify:</blurb> <list> - <bullet>degree of association between objects</bullet> - <bullet>containment</bullet> - <bullet>life-cycle</bullet> + <bullet>Degree of association between objects</bullet> + <bullet>Containment</bullet> </list> <image filename="one-to-many1.png" pdf-scale="0.9" y-offset="5.5"/> diff --git a/slides/mongodb/one-to-many2.xml b/slides/mongodb/one-to-many2.xml index 98fb129..1adc1cc 100644 --- a/slides/mongodb/one-to-many2.xml +++ b/slides/mongodb/one-to-many2.xml @@ -13,7 +13,7 @@ { time: 1350297729, ip: "192.168.42.103" }, { time: 1350298912, ip: "192.168.42.102" }, ] -}, +} { name: "What is PHP doing?", date: "2012-07-13", diff --git a/slides/mongodb/one-to-many4.xml b/slides/mongodb/one-to-many4.xml index 3eb4628..6ec9e72 100644 --- a/slides/mongodb/one-to-many4.xml +++ b/slides/mongodb/one-to-many4.xml @@ -9,7 +9,7 @@ { name: "Adam", text: "It was great having you in Sou..." }, { name: "Jake", text: "I don't think you can ever re..." }, ], -}, +} { _id: 7, name: "What is PHP doing?", date: "2012-07-13", @@ -19,8 +19,8 @@ }]]></example> <blurb>Views collection:</blurb> <example><![CDATA[ -{ article_id: 4, time: 1350297458, ip: "192.168.42.101" }, -{ article_id: 4, time: 1350298912, ip: "192.168.42.102" }, -{ article_id: 7, time: 1350297458, ip: "192.168.42.101" }, +{ article_id: 4, time: 1350297458, ip: "192.168.42.101" } +{ article_id: 4, time: 1350298912, ip: "192.168.42.102" } +{ article_id: 7, time: 1350297458, ip: "192.168.42.101" } ]]></example> </slide> diff --git a/slides/mongodb/query-advanced-ops.xml b/slides/mongodb/query-advanced-ops.xml index 3be864e..976b59a 100644 --- a/slides/mongodb/query-advanced-ops.xml +++ b/slides/mongodb/query-advanced-ops.xml @@ -1,11 +1,10 @@ <slide> <title>Advanced querying operators</title> -<blurb>Besides testing for exact matches, mongoDB also has operators. -Operators start with a '$', so make sure to use single quotes!</blurb> +<blurb>Operators start with a '$', so use single quotes!</blurb> <div effect="fade-out"> -<blurb>Compare:</blurb> +<blurb>Comparison:</blurb> <list> <bullet>$lt, $lte, $gt, $gte (<, <=, >, >=)</bullet> <bullet>$ne (not equal)</bullet> @@ -14,8 +13,7 @@ Operators start with a '$', so make sure to use single quotes!</blurb> </list> <blurb>Logical:</blurb> <list> - <bullet>$or (one needs to match)</bullet> - <bullet>$and (all need to match)</bullet> + <bullet>$or, $and</bullet> <bullet>$nor (not or)</bullet> <bullet>$not</bullet> </list> @@ -32,7 +30,7 @@ Operators start with a '$', so make sure to use single quotes!</blurb> </list> <blurb>Others:</blurb> <list> - <bullet>$type (check for type number, see <link href="http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24type"/>)</bullet> + <bullet>$type</bullet> </list> </div> </slide> diff --git a/slides/mongodb/query.xml b/slides/mongodb/query.xml index 280e6ee..ddb0e2a 100644 --- a/slides/mongodb/query.xml +++ b/slides/mongodb/query.xml @@ -9,7 +9,7 @@ $record = $m->demo->talks->findOne(); // Search on the _id field being 'derickr' $record = $m->demo->talks->findOne( array( '_id' => 'derickr' ) ); -// Search on the array element key 'title' in the 'talks' field +// Search on the 'talks' embedded document's 'title' field $record = $m->demo->talks->findOne( array( 'talks.title' => 'Xdebug' diff --git a/slides/mongodb/query2.xml b/slides/mongodb/query2.xml index 2eaf402..0e00b90 100644 --- a/slides/mongodb/query2.xml +++ b/slides/mongodb/query2.xml @@ -7,7 +7,7 @@ $m = new MongoClient(); // Find with 'projection' $record = $m->demo->talks->findOne( array( 'talks.title' => 'Xdebug' ), - array( 'name' => true, 'talks.url' => true ) + array( 'name' => 1, 'talks.url' => 1 ) ); ?>]]></example> </slide> diff --git a/slides/mongodb/tip-array-key.xml b/slides/mongodb/tip-array-key.xml index 669646b..25118da 100644 --- a/slides/mongodb/tip-array-key.xml +++ b/slides/mongodb/tip-array-key.xml @@ -1,22 +1,22 @@ <slide> -<title>Tips and hints: array keys</title> +<title>Tips and Hints: document keys</title> <blurb>Don't do:</blurb> <example><![CDATA[temperature: { _id: 42, points: [ { 1332942067: 17.3 }, - { 1332942118: 17.5 } + { 1332942118: 17.5 }, ] }]]></example> <break/> -<blurb>instead, do:</blurb> +<blurb>Instead, do:</blurb> <example><![CDATA[temperature: { _id: 42, points: [ { ts: 1332942067, temp: 17.3 }, - { ts: 1332942118, temp: 17.5 } + { ts: 1332942118, temp: 17.5 }, ] }]]></example> <break/> diff --git a/slides/mongodb/types-php.xml b/slides/mongodb/types-php.xml index b47169e..6295458 100644 --- a/slides/mongodb/types-php.xml +++ b/slides/mongodb/types-php.xml @@ -3,8 +3,8 @@ <list> <bullet>Unlike PHP, MongoDB does not type juggle</bullet> - <bullet>There is a date type, but it's UTC only (MongoDate)</bullet> - <bullet>When reading, everything will be an (associative) array, but never - an object</bullet> + <bullet>There is a date type, but it is only a Unix timestamp</bullet> + <bullet>When retrieving data, documents will be returned as an + (associative) array, but never as an object</bullet> </list> </slide> diff --git a/slides/mongodb/types.xml b/slides/mongodb/types.xml index ae3c312..c5768c1 100644 --- a/slides/mongodb/types.xml +++ b/slides/mongodb/types.xml @@ -4,13 +4,13 @@ <list> <bullet>null</bullet> <bullet>boolean</bullet> - <bullet>integer (both 32-bit and 64-bit, MongoInt32, MongoInt64)</bullet> + <bullet>integer (32 and 64-bit, MongoInt32, MongoInt64)</bullet> <bullet>double</bullet> <bullet>string (UTF-8)</bullet> <bullet>array</bullet> - <bullet>associative array ("object" for JavaScript)</bullet> - <bullet>MongoId (In the form of %4cb4ab6d7addf98506010000%)</bullet> - <bullet>MongoDate</bullet> - <bullet>MongoBinData</bullet> + <bullet>document (associative array in PHP)</bullet> + <bullet>ObjectIDs (MongoId)</bullet> + <bullet>UTC date (MongoDate)</bullet> + <bullet>Binary data (MongoBinData)</bullet> </list> </slide> diff --git a/slides/mongodb/update2a.xml b/slides/mongodb/update2a.xml index ffc247d..8b0a3f2 100644 --- a/slides/mongodb/update2a.xml +++ b/slides/mongodb/update2a.xml @@ -1,9 +1,9 @@ <slide> <title>Updating documents</title> -<blurb>Update only updates the *first* document it finds by default.</blurb> +<blurb>Update only modifies the *first* document it finds by default.</blurb> -<blurb>You can set an option to get all matching documents to be updated</blurb> +<blurb>You can set an option to modify *all* matched documents</blurb> <example result="0"><![CDATA[<?php $m = new MongoClient; @@ -16,7 +16,7 @@ $c->insert( [ '_id' => 'green-elephpant', 'generation' => 3, 'price' => 7.5 ] ); $c->update( [ 'generation' => [ '$lte' => 2 ] ], // criteria - [ '$dec' => [ 'price' => 2.0 ] ], // update spec + [ '$inc' => [ 'price' => -2.0 ] ], // update spec [ 'multiple' => true ] // options: multiple ); ?>]]></example>