Database Reference
In-Depth Information
Because of the richer data model, MongoDB can be considered a more general
solution to the problem of large, scalable web applications. MongoDB's scaling archi-
tecture is sometimes criticized because it's not inspired by Dynamo. But there are dif-
ferent scaling solutions for different domains. MongoDB's auto-sharding is inspired
by Yahoo!'s PNUTS data store and Google's BigTable. Anyone who reads the white
papers presenting these data stores will see that MongoDB's approach to scaling has
already been implemented, and successfully so.
R ELATIONAL DATABASES
Much has already been said of relational databases in this introduction, so in the inter-
est of brevity, I need only discuss what RDBMS s have with common with MongoDB and
where they diverge. MongoDB and MySQL 10 are both capable of representing a rich
data model, although where MySQL uses fixed-schema tables, MongoDB has schema-
free documents. MySQL and MongoDB both support B-tree indexes, and those accus-
tomed to working with indexes in MySQL can expect similar behavior in MongoDB.
MySQL supports both joins and transactions, so if you must use SQL or if you require
transactions, then you'll need to use MySQL or another RDBMS . That said,
MongoDB's document model is often rich enough to represent objects without
requiring joins. And its updates can be applied atomically to individual documents,
providing a subset of what's possible with traditional transactions. Both MongoDB and
MySQL support replication. As for scalability, MongoDB has been designed to scale
horizontally, with sharding and failover handled automatically. Any sharding on
MySQL has to be managed manually, and given the complexity involved, it's more
common to see a vertically scaled MySQL system.
D OCUMENT DATABASES
Few databases identify themselves as document databases. As of this writing, the only
well-known document database apart from MongoDB is Apache's CouchDB.
CouchDB's document model is similar, although data is stored in plain text as JSON ,
whereas MongoDB uses the BSON binary format. Like MongoDB, CouchDB supports
secondary indexes; the difference is that the indexes in CouchDB are defined by writ-
ing map-reduce functions, which is more involved than the declarative syntax used by
MySQL and MongoDB. They also scale differently. CouchDB doesn't partition data
across machines; rather, each CouchDB node is a complete replica of every other.
1.4.2
Use cases and production deployments
Let's be honest. You're not going to choose a database solely on the basis of its fea-
tures. You need to know that real businesses are using it successfully. Here I provide
a few broadly defined use cases for MongoDB and give some examples of its use in
production. 11
10
I'm using MySQL here generically, since the features I'm describing apply to most relational databases.
11
For an up-to-date list of MongoDB production deployments, see http://mng.bz/z2CH .
Search WWH ::




Custom Search