Multi model-databases 29-10-2014 LJC

1.809 Aufrufe

Veröffentlicht am

In many modern applications the database side is realized using polyglot persistence – store each data format (graphs, documents, etc.) in an appropriate separate database.
This approach yields several benefits, databases are optimized for their specific duty, however there are also drawbacks:
* keep all databases in sync
* queries might require data from several databases
* experts needed for all used systems

A multi-model database is not restricted to one data format, but can cope with several of them.
In this talk i will present how a multi-model database can be used in a polyglot persistence setup and how it will reduce the effort drastically.

Veröffentlicht in: Daten & Analysen
0 Kommentare
1 Gefällt mir
Statistik
Notizen
  • Als Erste(r) kommentieren

Keine Downloads
Aufrufe
Aufrufe insgesamt
1.809
Auf SlideShare
0
Aus Einbettungen
0
Anzahl an Einbettungen
43
Aktionen
Geteilt
0
Downloads
9
Kommentare
0
Gefällt mir
1
Einbettungen 0
Keine Einbettungen

Keine Notizen für die Folie

Multi model-databases 29-10-2014 LJC

  1. 1. www.arangodb.com Polyglot Persistence & Multi-Model Databases London Java Community 28-10-2014 Michael Hackstein @mchacki
  2. 2. Michael Hackstein ‣ ArangoDB Core Team ‣ Web Frontend ‣ Graph visualisation ‣ Graph features ! ! ‣ Host of cologne.js ! ! ‣ Master’s Degree (spec. Databases and Information Systems) 2
  3. 3. The Single Model era is over 3 Relational World
  4. 4. The Multi Model era begins ‣ Normally based on key-value stores (each document still 4 NoSQL World Documents - JSON { “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" } { “type“: "pants", “waist": 32, “length”: 34, “color": "blue", “material”: “cotton" } K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V has a unique key) ‣ Allow to save documents with logical similarity in “collections” ‣ Treat data records as attribute-structured documents (data is no more opaque) ‣ Often allow querying and indexing document attributes ‣ Focussed on m-to-n relations between entities ‣ Stores property graphs: entities and edges can have ‣ Easily query paths of variable length K => V K => V K => V K => V { “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" } attributes K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V K => V Graphs Key Value { “type“: "television", “diagonal screen size": 46, “hdmi inputs": 3, “wall mountable": true, “built-in digital tuner": true, “dynamic contrast ratio”: “50,000:1”, Resolution”: “1920x1080” } ‣ Map value data to unique string keys (identifiers) ‣ Treat data as opaque (data has no schema) ‣ Can implement scaling and partitioning easily
  5. 5. An e-commerce system in Relational World 5 Sales-History Shopping-Cart Recommendations Customer Product-Catalog
  6. 6. Polyglot Persistence 6 Shopping Cart Product Catalog MongoDB Reporting RDBMS Financial Data RDBMS Recommendations Neo4J Analytics Cassandra Product Catalog Document Source: Martin Fowler, http://martinfowler.com/articles/nosql-intro.pdf Riak User activity log Cassandra User Sessions Redis Shopping Cart KeyValue Reporting RDBMS Financial Data RDBMS Recommendations Graph Analytics Column User activity log Column User Sessions KeyValue
  7. 7. Single Model Databases 7 Sales-History Recommendations Customer { “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, } DocumentStore GraphStore DocumentStore { “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, } { “Name": "Smith", “lastLogin”: “2012-11-01", “Visits": 121, “shipping address”: “abc”, “shipping address”: “def” } { “Name": "Meyer", “lastLogin”: “2012-11-21", “Visits": 20, “shipping address”: “xyz”, } { “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" } { “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" } Shopping-Cart Product-Catalog 423453453 4328, “shirt”, “L”, 1, 12.99 6378, “sweater”, “M”, 2, 37.95 3245, “sweater”, “blue”, 1, 99.95 3245, “pants”, “32/34”, “black”, 1, 99.95 => 874365563 5463, “shirt”, “S”, 1, 9.99 6378, “sweater”, “M”, 2, 37.95 3245, “pants”, “32/34”, “black”, 1, 99.95 => { “type“: "pants", “waist": 32, “length”: 34, “color": "blue", “material”: “cotton" } { “type“: "television", “diagonal screen size": 46, “hdmi inputs": 3, “wall mountable": true, “built-in digital tuner": true, “dynamic contrast ratio”: “50,000:1”, Resolution”: “1920x1080” } KeyValueStore DocumentStore
  8. 8. Benefits ‣ Natural mapping of data into DB ‣ DB optimized for the data format ‣ Queries are tailored for your data format ‣ Focus on writing business logic 8 & Overhead ‣Data has to be stored redundantly and has to be kept in sync ‣Several technologies involved ‣Administration effort is huge
  9. 9. Solution: Multi Model Database ‣ Can natively store several kinds of data models: ‣ Key-value pairs ‣ Documents ‣ Graphs ‣ Delivers query mechanisms for all data models 9
  10. 10. Polyglot Persistence Revisited Financial Data ArangoDB Recommendations ArangoDB 10 User Sessions KeyValue Shopping Cart KeyValue Product Catalog Document Reporting RDBMS Financial Data RDBMS Recommendations Graph Analytics Column User activity log Column Shopping Cart ArangoDB Product Catalog ArangoDB Reporting RDBMS Source: Martin Fowler, http://martinfowler.com/articles/nosql-intro.pdf Analytics Cassandra User activity log Cassandra User Sessions ArangoDB
  11. 11. Use Case: Multi-Model-Databases 11 Sales-History Recommendations Customer { “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, } DocumentStore GraphStore DocumentStore { “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, } { “Name": "Smith", “lastLogin”: “2012-11-01", “Visits": 121, “shipping address”: “abc”, “shipping address”: “def” } { “Name": "Meyer", “lastLogin”: “2012-11-21", “Visits": 20, “shipping address”: “xyz”, } { “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" } { “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" } Shopping-Cart Product-Catalog 423453453 4328, “shirt”, “L”, 1, 12.99 6378, “sweater”, “M”, 2, 37.95 3245, “sweater”, “blue”, 1, 99.95 3245, “pants”, “32/34”, “black”, 1, 99.95 => 874365563 5463, “shirt”, “S”, 1, 9.99 6378, “sweater”, “M”, 2, 37.95 3245, “pants”, “32/34”, “black”, 1, 99.95 => { “type“: "pants", “waist": 32, “length”: 34, “color": "blue", “material”: “cotton" } { “type“: "television", “diagonal screen size": 46, “hdmi inputs": 3, “wall mountable": true, “built-in digital tuner": true, “dynamic contrast ratio”: “50,000:1”, Resolution”: “1920x1080” } KeyValueStore DocumentStore
  12. 12. My four favorite features of ‣ AQL offering joins & traversals ‣ ACID including Multi Collection Transactions ‣ MULTI-MODEL stores graphs and documents 12 ‣ FOXX extend the API and adapt it to your needs
  13. 13. AQL ‣Document Query: FOR user IN users FILTER user.active == true FOR game IN games FILTER game.player == user._id RETURN { username: user.name, score: game.score } ‣ Modify Documents: FOR u IN users FILTER u.status == 'not active' UPDATE u WITH { active: false } IN users ! ‣ Graph Traversal: RETURN GRAPH_TRAVERSAL( "underground_plan", „stations/main_station", "outbound", {minDepth: 2, maxDepth: 5} ) 13
  14. 14. ACID - Transactions ‣ Invoke a transaction: db._executeTransaction({ collections: { write: ["users", "products"], read: "recommendations" }, action: function() { // all operations go here ! } }); 14 throw "failure"; // Triggers rollback
  15. 15. Benefits & Overhead ‣ Native mapping of data into DB ‣ DB optimized ‣ Queries are tailored for your data format ‣ Focus on writing business logic 15 ‣Data has to be stored redundantly and has to be kept in sync ‣Several technologies ‣Administration effort is ‣One technology involved
  16. 16. Foxx ‣ Add your own customized and versioned REST-API on top of ArangoDB in JavaScript ‣ Include as a web service in Rails, Node.js etc. ‣ Use as storage for Web-frameworks like AngularJS, EmberJS, Backbone etc. ‣ Built-in authentication using OAuth2.0 or HTTP-Basic Auth ‣ Operations are encapsulated in the database ‣ low network traffic, direct data access ‣ increases data privacy ➡Multi-device setups ➡Microservices / (~( ) ) /_/ ( _-----_(@ @) ( / /|/--| V " " " " 16
  17. 17. ‣ open source and free (Apache 2 license) ‣ sharding & replication ‣ JavaScript throughout (V8 built into server) ‣ drivers for a wide range of languages ‣ web frontend ‣ good & complete documentation ‣ professional as well as community support 17 An overview of other features
  18. 18. Join our growing community 18 .. working on the geo index, the full text search and many APIs: Ruby, Python, PHP, Java, D, Javascript, ...
  19. 19. Thank you ! ! ! ‣ Further questions? ‣ Follow me on twitter/github: @mchacki ‣ Write me a mail: mchacki@arangodb.com ‣ Join or google group: https://groups.google.com/forum/#!forum/arangodb 19

×