Document-Oriented DatabaseJohn Sercel
Document vs. RelationalRelational databaseTables -> RecordsDefined schemaDocument-oriented databaseCollections -> DocumentsNo schemaJohn Sercel | 2
MongoDBLanguage driversC, C++, Java, Javascript, Perl, PHP, Python, Ruby, etc.OS SupportOS X, Linux, Windows, SolarisOpen Source, FreeSupportCommunityCommercialJohn Sercel | 3
Installation: Windows, LinuxQuick, easy installationDownloadUnzip the archive fileCreate a data directory: /data/db (c:\data\db)Start MongoDB Server./bin/mongod[bin\mongod.exe]Start MongoDB Client./bin/mongo 	[bin\mongo.exe]John Sercel | 4
MongoDB BasicsBasic commandsList databases:	show dbsSelect database:	use [db name]Insert documentdb.myCollection.insert({‘myKey’ : ‘myValue’, ‘anotherKey’ : ‘anotherValue’ })John Sercel | 5
MongoDB BasicsSelect documents (MongoDB)db.myCollection.find()db.myCollection.find({‘name’ : ‘John Doe’})Select documents (SQL)SELECT * FROM myTable		SELECT * FROM myTable WHERE name = ‘John Doe’John Sercel | 6
Connecting MongoDB: PHPInstall MongoDB PHP ExtensionSource, PHP Extension Community Library (PECL)Update configuration fileRestart server softwareJohn Sercel | 7
Connecting MongoDB: PHPPHP ExampleInsert new document			$connection = new Mongo();			$collection = $connection->databaseName->collectionName;			$document = array( "name" => “John Doe”);			$collection->insert($document);Select document(s)			$documents = $collection->find();John Sercel | 8
Why Document-Oriented?Storing unique documentsNon-standard field set in each entitySpeed vs. NormalizationNormalization decreases redundancy, and speed.Relational operations are expensiveSimple data storage preferable for heavy useBigTable, CassandraJohn Sercel | 9
ReferencesMongoDB. (2009a). Mongodb-10gen confluence website. Retrieved February 5, 2010 from http://www.mongodb.org/MongoDB. (2009b). Quickstart-mongodb. Retrieved February 8, 2010 from http://www.mongodb.org/display/DOCS/Quickstart /MongoDB. (2009c). Developer zone-mongodb. Retrieved February 8, 2010 from http://www.mongodb.org/display/DOCS/Developer+Zone/The PHP Group. (2009). Php manual-mongo. Retrieved February 5, 2010 from http://us3.php.net/manual/en/mongo.manual.phpJohn Sercel | 10

MongoDB

  • 1.
  • 2.
    Document vs. RelationalRelationaldatabaseTables -> RecordsDefined schemaDocument-oriented databaseCollections -> DocumentsNo schemaJohn Sercel | 2
  • 3.
    MongoDBLanguage driversC, C++,Java, Javascript, Perl, PHP, Python, Ruby, etc.OS SupportOS X, Linux, Windows, SolarisOpen Source, FreeSupportCommunityCommercialJohn Sercel | 3
  • 4.
    Installation: Windows, LinuxQuick,easy installationDownloadUnzip the archive fileCreate a data directory: /data/db (c:\data\db)Start MongoDB Server./bin/mongod[bin\mongod.exe]Start MongoDB Client./bin/mongo [bin\mongo.exe]John Sercel | 4
  • 5.
    MongoDB BasicsBasic commandsListdatabases: show dbsSelect database: use [db name]Insert documentdb.myCollection.insert({‘myKey’ : ‘myValue’, ‘anotherKey’ : ‘anotherValue’ })John Sercel | 5
  • 6.
    MongoDB BasicsSelect documents(MongoDB)db.myCollection.find()db.myCollection.find({‘name’ : ‘John Doe’})Select documents (SQL)SELECT * FROM myTable SELECT * FROM myTable WHERE name = ‘John Doe’John Sercel | 6
  • 7.
    Connecting MongoDB: PHPInstallMongoDB PHP ExtensionSource, PHP Extension Community Library (PECL)Update configuration fileRestart server softwareJohn Sercel | 7
  • 8.
    Connecting MongoDB: PHPPHPExampleInsert new document $connection = new Mongo(); $collection = $connection->databaseName->collectionName; $document = array( "name" => “John Doe”); $collection->insert($document);Select document(s) $documents = $collection->find();John Sercel | 8
  • 9.
    Why Document-Oriented?Storing uniquedocumentsNon-standard field set in each entitySpeed vs. NormalizationNormalization decreases redundancy, and speed.Relational operations are expensiveSimple data storage preferable for heavy useBigTable, CassandraJohn Sercel | 9
  • 10.
    ReferencesMongoDB. (2009a). Mongodb-10genconfluence website. Retrieved February 5, 2010 from http://www.mongodb.org/MongoDB. (2009b). Quickstart-mongodb. Retrieved February 8, 2010 from http://www.mongodb.org/display/DOCS/Quickstart /MongoDB. (2009c). Developer zone-mongodb. Retrieved February 8, 2010 from http://www.mongodb.org/display/DOCS/Developer+Zone/The PHP Group. (2009). Php manual-mongo. Retrieved February 5, 2010 from http://us3.php.net/manual/en/mongo.manual.phpJohn Sercel | 10