Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MongoDB

3,326 views

Published on

Published in: Technology
  • Be the first to comment

MongoDB

  1. 1. Document-Oriented Database<br />John Sercel<br />
  2. 2. Document vs. Relational<br />Relational database<br />Tables -&gt; Records<br />Defined schema<br />Document-oriented database<br />Collections -&gt; Documents<br />No schema<br />John Sercel | 2<br />
  3. 3. MongoDB<br /><ul><li>Language drivers</li></ul>C, C++, Java, Javascript, Perl, PHP, Python, Ruby, etc.<br />OS Support<br />OS X, Linux, Windows, Solaris<br />Open Source, Free<br />Support<br />Community<br />Commercial<br />John Sercel | 3<br />
  4. 4. Installation: Windows, Linux<br /><ul><li>Quick, easy installation</li></ul>Download<br />Unzip the archive file<br />Create a data directory: /data/db (c:datadb)<br />Start MongoDB Server<br />./bin/mongod[binmongod.exe]<br />Start MongoDB Client<br />./bin/mongo [binmongo.exe]<br />John Sercel | 4<br />
  5. 5. MongoDB Basics<br /><ul><li>Basic commands</li></ul>List databases: show dbs<br />Select database: use [db name]<br />Insert document<br />db.myCollection.insert({‘myKey’ : ‘myValue’, ‘anotherKey’ : ‘anotherValue’ })<br />John Sercel | 5<br />
  6. 6. MongoDB Basics<br /><ul><li>Select documents (MongoDB)</li></ul>db.myCollection.find()<br />db.myCollection.find({‘name’ : ‘John Doe’})<br /><ul><li>Select documents (SQL)</li></ul>SELECT * FROM myTable<br /> SELECT * FROM myTable WHERE name = ‘John Doe’<br />John Sercel | 6<br />
  7. 7. Connecting MongoDB: PHP<br /><ul><li>Install MongoDB PHP Extension</li></ul>Source, PHP Extension Community Library (PECL)<br />Update configuration file<br />Restart server software<br />John Sercel | 7<br />
  8. 8. Connecting MongoDB: PHP<br /><ul><li>PHP Example</li></ul>Insert new document<br /> $connection = new Mongo();<br /> $collection = $connection-&gt;databaseName-&gt;collectionName;<br /> $document = array( &quot;name&quot; =&gt; “John Doe”);<br /> $collection-&gt;insert($document);<br />Select document(s)<br /> $documents = $collection-&gt;find();<br />John Sercel | 8<br />
  9. 9. Why Document-Oriented?<br /><ul><li>Storing unique documents</li></ul>Non-standard field set in each entity<br />Speed vs. Normalization<br />Normalization decreases redundancy, and speed.<br />Relational operations are expensive<br />Simple data storage preferable for heavy use<br />BigTable, Cassandra<br />John Sercel | 9<br />
  10. 10. References<br />MongoDB. (2009a). Mongodb-10gen confluence website. Retrieved February 5, 2010 from http://www.mongodb.org/<br />MongoDB. (2009b). Quickstart-mongodb. Retrieved February 8, 2010 from http://www.mongodb.org/display/DOCS/Quickstart /<br />MongoDB. (2009c). Developer zone-mongodb. Retrieved February 8, 2010 from http://www.mongodb.org/display/DOCS/Developer+Zone/<br />The PHP Group. (2009). Php manual-mongo. Retrieved February 5, 2010 from http://us3.php.net/manual/en/mongo.manual.php<br />John Sercel | 10<br />

×