This document provides an overview of MongoDB, an open-source, schema-free, document-oriented database. It discusses how MongoDB offers more flexibility and scalability compared to traditional RDBMS systems. Key features covered include dynamic queries, replication, auto-sharding, and support for many platforms/languages. Examples are given for common operations like creating, querying, and updating document structures in MongoDB.
22. New post
post = {“author”: “mike”,
“date”: datetime.datetime.utcnow(),
“text”: “my blog post...”,
“tags”: [“mongodb”, “python”, “ruby”]}
post_id = db.posts.save(post)
23. Embedding a comment
c = {“author”: “eliot”,
“date”: datetime.datetime.utcnow(),
“text”: “great post!”}
db.posts.update({“_id”: post_id},
{“$push”: {“comments”: c}})
35. Terminology
• Shard key
• Chunk
• Range of the value space
• (collection, key, min_val, max_val)
• Shard
• Single node (or replica pair)
• Responsible for set of chunks