MongoDB
Open-source, high-performance, document-
- riented database
MongoDB Open-source, high-performance , document- oriented database - - PowerPoint PPT Presentation
MongoDB Open-source, high-performance , document- oriented database Jay Urbain, PhD https://docs.mongodb.com/ Modern Databases Non-relational data stores (NoSQL) Key/value Horizontal scalability, no table joins Hive,
– Key/value – Horizontal scalability, no table joins – Hive, Dynamo, Big Table, CouchDB, Redis, MongoDB,…
– Dimensional data model – Column store – Vertica, Aster, Greenplum
– Relational model – Transaction oriented – Oracle, MySQL, PostgreSQL
BASE (Basically Available, Soft State, Eventual consistency) analysis of NoSQL. ACID (Atomicity, Consistency, Isolation, and Durability) versus BASE. CAP theorem – get 2 of 3: consistency, availability, partition tolerance
group, etc.
general purpose data store.
horizontal scaling, and geographic distribution are built in and easy to use.
– MongoDB scales horizontally using sharding. – MongoDB can run over multiple servers, balancing the load or duplicating data to keep the system up and running in case of hardware failure.
document to document and the data structure can be changed over time.
making data easy to work with. No object-relational mapping.
access and analyze your data
secondary indices.
binary-encoded serialization of JSON-like documents
– Scaling out – Caching – The Web – High volume – Simple data models
– Highly transactional – Ad-hoc business intelligences – Problems that require SQL – Complex relational data models
– query – JSON object of matching properties to identify the document to update – data – JSON object specifying the properties to update – callback – function that is called with the number of modified documents
Python: tasks_results = mongo.db.tasks _id = tasks_results.insert(task_)
Javascript:
Demo MongoDB curl commands if time tasks_results = mongo.db.tasks result = tasks_results.delete_one({"id": str(task_id)}) Javascript: Python:
Example usage (serialization): >>> from bson import Binary, Code >>> from bson.json_util import dumps >>> dumps([{'foo': [1, 2]}, ... {'bar': {'hello': 'world'}}, ... {'code': Code("function x() { return 1; }", {})}, ... {'bin': Binary(b"")}]) '[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$code": "function x() { return 1; }", "$scope": {}}}, {"bin": {"$binary": "AQIDBA==", "$type": "00"}}]'
Example usage (deserialization): >>> from bson.json_util import loads >>> loads('[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$scope": {}, "$code": "function x() { return 1; }"}}, {"bin": {"$type": "80", "$binary": "AQIDBA=="}}]') [{u'foo': [1, 2]}, {u'bar': {u'hello': u'world'}}, {u'code': Code('function x() { return 1; }', {})}, {u'bin': Binary('...', 128)}]