> show dbs;
local 0.078125GB
> use drupal;
> show collections;
> db.awesomestuff.insert({"a":1, "b":2});
> db.awesomestuff.find();
{"_id":ObjectId("526965cd93259605e9afbc41"), "a":1, "b":2}
> show collections;
system.indexes
awesomestuff
> show dbs;
drupal 0.203125GB
local 0.078125GB
> db.awesomestuff.insert({
"a": [1, 2, 3], "b":"some string"
});
> db.awesomestuff.insert({
"a": [[1,2,4], [4,5,6], [7,8,9]]
});
> db.awesomestuff.insert({
"a": {
"name" : "Dries",
"interests" : ["Drupal", "MongoDB"]
}
);
MySQL | MongoDB |
---|---|
database | database |
table | collection |
row | document |
column | field |
index | index |
joins | embedded documents and linking |
persistent, easy to set-up, fast ("fire and forget"), automatic garbage collection
Photo by http://www.webdesignerdepot.com/2009/03/40-comics-strips-for-web-designers/easy to set-up, fast ("fire and forget"), very good for multi-server envs, uses capped collections
Photo by Which? Campaigns - http://www.flickr.com/photos/71528417@N02/6709386951easy to set-up, per-queue-collection
Photo by Darren Tunnicliff - http://www.flickr.com/photos/25572591@N07/3717976312a bit funky :), stores blocks configuration, exposes UI
Photo by capitaine_commerce - http://www.flickr.com/photos/8488292@N04/1807465667stores entites /w fields as Mongo docs, still needs base entity table, lazy destruction of stale data, new fields added very easily
Photo by Aleksej Leonov - http://www.flickr.com/photos/31849470@N02/7652495954
{
"_id" : 60549286,
"_type" : "node",
"_bundle" : "story",
"_revision_id" : 150412786,
"nid" : 60549286,
"vid" : 150412786,
"type" : "story",
"language" : "und",
"title" : "Hello world!",
"uid" : 2044271,
"status" : 1,
"created" : 1364855903,
"changed" : 1364855940,
"comment" : 2,
"promote" : 1,
"sticky" : 0,
"field_image" : {
"fid" : 47928616,
"width" : 594,
"height" : 396,
"alt" : "",
"title" : ""
},
"body" : {
"value" : "MongoDB is great!
"
},
"field_tags" : [
{ "tid" : 14244596 },
{ "tid" : 14244596 }
]
}
www.google-melange.com/gci/homepage/google/gci2013 | @slurpee on #drupal-gci