Relational databases are central to web applications, but they have also been the primary source of pain when it comes to scale and performance. Recently, non-relational databases (also referred to as NoSQL) have arrived on the scene. This session explains not only what MongoDB is and how it works, but when and how to gain the most benefit.
5. “Alternative” databases?
What’s the point?
Relational databases » relational algebra » set theory
ORM “impedance mismatch”
Failed alternatives reinforced the status quo
6. What’s a document database?
Composed of documents ...duh
Each document is heterogenous, and may have a
completely unique structure compared to other
documents
...That’s pretty much it
7. Why Mongo?
.org :
“The best features of document databases,
key-value stores, and relational databases.”
10. Common Tasks
tags
id
MySQL
name
posts_tags
id posts comments
post_id id id
tag_id title post_id
slug author
body email
published body
created created
updated
11. Common Tasks id
posts
title
slug
MongoDB body
published
created
updated
comments
author
email
body
created
tags
12. Common Tasks
MongoDB
{
"_id" : ObjectId("4c03e856e258c2701930c091"),
"title" : "Welcome to MongoDB",
"slug" : "welcome-to-mongodb",
"body" : "Today, we're gonna totally rock your world...",
"published" : true,
"created" : "Mon May 31 2010 12:48:22 GMT-0400 (EDT)",
"updated" : "Mon May 31 2010 12:48:22 GMT-0400 (EDT)",
"comments" : [
{
"author" : "Bob",
"email" : "bob@example.com",
"body" : "My mind has been totally blown!",
"created" : "Mon May 31 2010 12:48:22 GMT-0400 (EDT)"
}
],
"tags" : [
"databases", "MongoDB", "awesome"
]
}
44. Drupal for MongoDB
http://drupal.org/project/mongodb
D7: mongodb_cache: Store cache items in mongodb
D7: mongodb_field_storage: Store the fields in mongodb
D7: mongodb_session: Store sessions in mongodb
D6/D7: mongodb_watchdog: Store the watchdog messages in mongodb
D6/D7: mongodb: support library for the other modules
D7: mongodb_block: Store block information in mongodb. Very close to the core
block API
D7: mongodb_queue: DrupalQueueInterface implementation using mongodb
http://sf2010.drupal.org/conference/sessions/mongodb-humongous-drupal
45. Even MORE Drupal
Work to get listing API into core:
http://drupal.org/node/780154
Experimental goodies to play with:
http://drupalcode.org/viewvc/drupal/contributions/
sandbox/chx/dbtng_mongo_experimental/
46. Joomla!
MongoDB helper library for Joomla!
Branch of 1.6 development for alternative query builder
Full MongoDB support most likely in 2.0
47. Lithium PHP framework
MongoDB native support since 0.2
http://rad-dev.org/lithium/wiki
Projects demonstrating MongoDB support:
http://rad-dev.org/lithium_mongo/source
http://rad-dev.org/lithium_blog/source