NoSQL Database - mongodb Andreas Hartmann 19.10.11
Agenda NoSQL Basics MongoDB Basics Map/Reduce Binary Data Sets Replication - Scaling Monitoring - Backup Schema Design - Ecosystem 19.10.11 2 NoSQL Database - mongodb
NoSQL Basics CAP Theorem Availability All clients can always read and write Consistency Each client always has the same view of the data Partition tolerance The system works well across physical network partitions 2000; Prof. Eric A. Brewer; Keynote auf dem ACM Symposium über die Prinzipien verteilten Computing 2002; Seth Gilbert und Nancy Lynch vom MIT formal bewiesen 19.10.11 3 NoSQL Database - mongodb
NoSQL Basics ACID-BASE ACID Atomicity all or nothing rule Consistency any transaction the database performs will take it from one consistent state to another Isolation no transaction should be able to interfere with another transaction at all Durability once a transaction has been committed, it will remain so http://en.wikipedia.org/wiki/acid BASE Basically Available the system does guarantee availability, in terms of the CAP theorem Soft-State the state of the system may change over time, even without input Eventual Consistency the system will become consistent over time, given that the system doesn't receive input during that time http://stackoverflow.com/questions/3342497/explanation-ofbase-terminology 19.10.11 4 NoSQL Database - mongodb
NoSQL Basics Documentoriented Conceptual: nested Structures with extendable Attributes name forname adress street postcode city... Meier Max Deich 7 28355 Bremen???.................. Internal: document oriented View (mostly JSON-Format) {"name":"meier", "forname":"max", "adress":{"street":"deich 7", "postcode":28355, "city":"bremen"} "...":"???"} 19.10.11 5 NoSQL Database - mongodb
mongodb - Basics Datatypes JavaScript Object Notation (JSON) string, integer, boolean,... {"conference": "wjax"} Binary JSON (BSON) date, object id, binary data,... "\x16\x00\x00\x00\x02conference\x00 \x06\x00\x00\x00wjax\x00\x00" 19.10.11 6 NoSQL Database - mongodb
mongodb - Basics SQL to Mongo Mapping SQL Mongo Database Table Index Row Column Join Primary Key Database Collection Index BSON Document BSON Field Embedding an Linking _id Field 19.10.11 7 NoSQL Database - mongodb
mongodb - Basics Mongo Metadata system.namespaces system.indexes system.profile system.users local.sources 19.10.11 8 NoSQL Database - mongodb
mongodb - Basics Collectiontypes Collection db.createcollection("mycollection"); Capped Collection > Logging > Caching > Archiving db.createcollection( "mycappedcollection", {capped:true, size:100000, max:100}); 19.10.11 9 NoSQL Database - mongodb
mongodb - Basics ObjectId Document db.person.insert( {"name": "Name 1", "forname": "Forname 1", "email": "email1@adesso.de" } ); 19.10.11 10 NoSQL Database - mongodb
mongodb - Basics Embedded Document db.person.insert( {"name": "Name 1", "forname": "Forname 1", "email": "email1@adesso.de", "adress": { "street": "Street 1", "city": "City 1", "postcode": 1 } } ); 19.10.11 11 NoSQL Database - mongodb
mongodb - Basics DBRef var lastperson = db.person.findone(); db.hotel.insert( {"name": "Motel 1", "stars": 3, "adress": { "adress": "Adress 4", "city": "City", "postcode": 4 }, "guest": [ { "$ref" : "person", "$id" : lastperson._id } ]}); 19.10.11 12 NoSQL Database - mongodb
mongodb - Basics CRUD Samples Connectivity (Client Treiber) 19.10.11 13 NoSQL Database - mongodb
mongodb - Selectors Queries Modifiers Aggregationen 19.10.11 14 NoSQL Database - mongodb
mongodb - Transactions Atomic Updates Update-If-current Principle 19.10.11 15 NoSQL Database - mongodb
mongodb - Indices Simple Indices Compound Indices Unique Indices Sorting Order 19.10.11 16 NoSQL Database - mongodb
mongodb Map/Reduce Parallel processing huge datasets on distributed systems Data Data Data Data M A P R E D U C E 19.10.11 17 NoSQL Database - mongodb
mongodb Map/Reduce mongodb API 19.10.11 18 NoSQL Database - mongodb
mongodb Binary Data Sets GridFS 19.10.11 19 NoSQL Database - mongodb
mongodb Replication Recplica Sets 19.10.11 20 NoSQL Database - mongodb
mongodb - Scaling Sharding 19.10.11 21 NoSQL Database - mongodb
mongodb - Monitoring 19.10.11 22 NoSQL Database - mongodb
mongodb - Backup 19.10.11 23 NoSQL Database - mongodb
mongodb Schema Design denormalize avoid relations implements relations > Object ID > DBRef embedet documents one to many many to many 19.10.11 24 NoSQL Database - mongodb
mongodb Schema Design Many to Many User id name UserRole userid userrole Role id name 19.10.11 25 NoSQL Database - mongodb
mongodb Schema Design Many to Many {"_id":"3456768789", "name":"andreas", "roles":{"developer", "Architect", "Coach", "Speaker"}} {"_id":"2896823412", "name":"max", "roles":{"developer", "Student"}} 19.10.11 26 NoSQL Database - mongodb
mongodb - Ecosystem MongoExplorer Morphia 19.10.11 27 NoSQL Database - mongodb
Hands On 19.10.11 28 NoSQL Database - mongodb
Vielen Dank für Ihre Aufmerksamkeit. info@adesso.de www.adesso.de
19.10.11 30 NoSQL Database - mongodb