Polyglot Persistence & Multi-Model Databases
-
Upload
arangodb -
Category
Technology
-
view
666 -
download
0
Transcript of Polyglot Persistence & Multi-Model Databases
![Page 1: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/1.jpg)
www.arangodb.com
Polyglot Persistence &
Multi-Model Databases
Michael Hackstein @mchacki
Java User Group Hessen
![Page 2: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/2.jpg)
Michael Hackstein
‣ ArangoDB Core Team ‣ Web Frontend ‣ Graph visualisation ‣ Graph features
‣ Host of cologne.js
‣ Master’s Degree(spec. Databases and Information Systems)
2
![Page 3: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/3.jpg)
The Single Model era is over
3
Relational World
![Page 4: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/4.jpg)
The Multi Model era begins
4
NoSQL WorldDocuments - JSON
Graphs
Key Value
{ “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
![Page 5: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/5.jpg)
The Multi Model era begins
4
NoSQL WorldDocuments - JSON
Graphs
Key Value
{ “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
‣ Normally based on key-value stores (each document still 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
![Page 6: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/6.jpg)
The Multi Model era begins
4
NoSQL WorldDocuments - JSON
Graphs
Key Value
{ “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
‣ Focussed on m-to-n relations between entities ‣ Stores property graphs: entities and edges can have
attributes ‣ Easily query paths of variable length
‣ Normally based on key-value stores (each document still 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
![Page 7: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/7.jpg)
The Multi Model era begins
4
NoSQL WorldDocuments - JSON
Graphs
Key Value
{ “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
‣ Map value data to unique string keys (identifiers) ‣ Treat data as opaque (data has no schema) ‣ Can implement scaling and partitioning easily
‣ Focussed on m-to-n relations between entities ‣ Stores property graphs: entities and edges can have
attributes ‣ Easily query paths of variable length
‣ Normally based on key-value stores (each document still 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
![Page 8: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/8.jpg)
e-commerce system in Relational World
5
Sales-History
Shopping-Cart
Recommendations Customer
Product-Catalog
![Page 9: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/9.jpg)
Polyglot Persistence
6
Source: Martin Fowler, http://martinfowler.com/articles/nosql-intro.pdf
Reporting
RDBMS
Product Catalog
MongoDB
Shopping Cart
Riak
User activity log
Cassandra
Analytics
Cassandra
Recommendations
Neo4J
Financial Data
RDBMS
User Sessions
Redis
![Page 10: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/10.jpg)
Polyglot Persistence
6
Source: Martin Fowler, http://martinfowler.com/articles/nosql-intro.pdf
Reporting
RDBMS
Product Catalog
MongoDB
Shopping Cart
Riak
User activity log
Cassandra
Analytics
Cassandra
Recommendations
Neo4J
Financial Data
RDBMS
User Sessions
Redis
Shopping Cart
KeyValue
Reporting
RDBMS
Product Catalog
Document
User activity log
Column
Analytics
Column
Recommendations
Graph
Financial Data
RDBMS
User Sessions
KeyValue
![Page 11: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/11.jpg)
Single Model Databases
7
Recommendations
Product-CatalogShopping-Cart
Sales-History Customer
{ “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, }
{ “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”, }
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
=>
8743655635463, “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
![Page 12: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/12.jpg)
Single Model Databases
7
Recommendations
Product-CatalogShopping-Cart
Sales-History Customer
{ “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, }
{ “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”, }
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
=>
8743655635463, “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
DocumentStore GraphStore DocumentStore
DocumentStoreKeyValueStore
![Page 13: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/13.jpg)
Single Model Databases
7
Recommendations
Product-CatalogShopping-Cart
Sales-History Customer
{ “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, }
{ “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”, }
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
=>
8743655635463, “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
DocumentStore GraphStore DocumentStore
DocumentStoreKeyValueStore
![Page 14: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/14.jpg)
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
‣Data has to be stored redundantly and has to be kept in sync ‣Several technologies involved ‣Administration effort is huge
Overhead&
![Page 15: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/15.jpg)
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
![Page 16: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/16.jpg)
Polyglot Persistence Revisited
10
Source: Martin Fowler, http://martinfowler.com/articles/nosql-intro.pdf
Shopping Cart
KeyValue
Reporting
RDBMS
Product Catalog
Document
User activity log
Column
Analytics
Column
Recommendations
Graph
Financial Data
RDBMS
User Sessions
KeyValue
![Page 17: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/17.jpg)
Polyglot Persistence Revisited
10
Source: Martin Fowler, http://martinfowler.com/articles/nosql-intro.pdf
Shopping Cart
KeyValue
Reporting
RDBMS
Product Catalog
Document
User activity log
Column
Analytics
Column
Recommendations
Graph
Financial Data
RDBMS
User Sessions
KeyValue
Reporting
RDBMS
Product Catalog
ArangoDB
Shopping Cart
ArangoDB
User activity log
Cassandra
Analytics
Cassandra
Recommendations
ArangoDB
Financial Data
ArangoDB
User Sessions
ArangoDB
![Page 18: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/18.jpg)
Use Case: Multi-Model-Databases
11
Recommendations
Product-CatalogShopping-Cart
Sales-History Customer
{ “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, }
{ “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”, }
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
=>
8743655635463, “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
![Page 19: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/19.jpg)
Use Case: Multi-Model-Databases
11
Recommendations
Product-CatalogShopping-Cart
Sales-History Customer
{ “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, }
{ “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”, }
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
=>
8743655635463, “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
DocumentStore GraphStore DocumentStore
DocumentStoreKeyValueStore
![Page 20: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/20.jpg)
Use Case: Multi-Model-Databases
11
Recommendations
Product-CatalogShopping-Cart
Sales-History Customer
{ “userID": 239178239, “productID”: 128623883, “number": 5, “price”: 12.20, }
{ “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”, }
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
=>
8743655635463, “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” }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
{ “type": "sweater", “color": "blue", “size": “M”, “material”: “wool”, “form”: “turtleneck" }
DocumentStore GraphStore DocumentStore
DocumentStoreKeyValueStore
![Page 21: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/21.jpg)
My four favorite features of
‣ AQL offering joins & traversals ‣ ACID including Multi Collection Transactions ‣ MULTI-MODEL stores graphs and documents
12
![Page 22: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/22.jpg)
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
![Page 23: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/23.jpg)
AQL
13
FOR user IN users RETURN user
![Page 24: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/24.jpg)
AQL
14
FOR user IN users FILTER user.name == "alice" RETURN user
![Page 25: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/25.jpg)
AQL
15
FOR user IN users FILTER user.name == "alice" FOR invoice IN invoices FILTER user._key == invoice.customer RETURN { user: user, invoice: invoice }
![Page 26: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/26.jpg)
AQL
16
FOR user IN users FILTER user.name == "alice" RETURN { user: user, invoices: ( FOR invoice IN invoices FILTER user._key == invoice.customer RETURN invoice ) }
![Page 27: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/27.jpg)
AQL
17
FOR user IN users FILTER user.name == "alice" RETURN { user: user, hasToPay: SUM( FOR invoice IN invoices FILTER user._key == invoice.customer FILTER !invoice.payed RETURN invoice.price ) }
![Page 28: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/28.jpg)
AQL - Alternative
18
FOR user IN users FILTER user.name == "alice" FOR invoice IN invoices FILTER user._key == invoice.customer FILTER !invoice.payed COLLECT u = user AGGREGATE toPay = SUM(invoice.price) RETURN { user: u, hasToPay: toPay }
![Page 29: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/29.jpg)
AQL
19
FOR user IN users FILTER user.name == "alice" FOR product IN OUTBOUND user has_bought RETURN product
![Page 30: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/30.jpg)
AQL
20
FOR user IN users FILTER user.name == "alice" FOR product IN OUTBOUND user has_bought LIMIT 10 RETURN product
![Page 31: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/31.jpg)
AQL
21
FOR user IN users FILTER user.name == "alice" FOR product, action IN OUTBOUND user has_bought SORT action.timestamp DESC LIMIT 10 RETURN product
![Page 32: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/32.jpg)
AQL
22
FOR user IN users FILTER user.name == "alice" FOR recommendation IN 3 ANY user has_bought OPTIONS { bfs: true, uniqueVertices: "global" } LIMIT 10 RETURN recommendation
![Page 33: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/33.jpg)
AQL
23
FOR user IN users FILTER user.name == "alice" FOR recommendation, action, path IN 3 ANY user has_bought FILTER path.vertices[2].age <= user.age + 5 AND path.vertices[2].age >= user.age - 5 LIMIT 10 RETURN recommendation
![Page 34: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/34.jpg)
AQL
24
FOR user IN users FILTER user.name == "alice" FOR recommendation, action, path IN 3 ANY user has_bought FILTER path.vertices[2].age <= user.age + 5 AND path.vertices[2].age >= user.age - 5 FILTER recommendation.price < 25 LIMIT 10 RETURN recommendation
![Page 35: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/35.jpg)
ACID - Transactions
‣ Invoke a transaction: db._executeTransaction({ collections: { write: ["users", "products"], read: "has_bought" }, action: function() { // all operations go here
} });
25
![Page 36: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/36.jpg)
ACID - Transactions
‣ Invoke a transaction: db._executeTransaction({ collections: { write: ["users", "products"], read: "has_bought" }, action: function() { // all operations go here
} });
25
throw "failure"; // Triggers rollback
![Page 37: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/37.jpg)
‣ Native mapping of data into DB ‣ DB optimized ‣ Queries are tailored for your
data format ‣ Focus on writing business logic
26
‣Data has to be stored redundantly and has to be kept in sync
‣Several technologies involved
‣Administration effort is huge
Benefits Overhead&
![Page 38: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/38.jpg)
‣ Native mapping of data into DB ‣ DB optimized ‣ Queries are tailored for your
data format ‣ Focus on writing business logic
26
‣ One technology involved
Benefits Overhead&
![Page 39: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/39.jpg)
Benchmark Comparison
Source: https://www.arangodb.com/2015/10/benchmark-postgresql-mongodb-arangodb/
![Page 40: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/40.jpg)
Foxx
‣ Add your own customized and versioned REST-API on top of ArangoDB in JavaScript ‣ Include as a microservice in Rails, Node.js etc. ‣ Ship an administration fronted with it
‣ 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 ➡Microservice Architectures
/\ (~( ) ) /\_/\ ( _-----_(@ @) ( \ / /|/--\|\ V " " " "
28
![Page 41: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/41.jpg)
Foxx Example
29
router.get("/recommend/:price", function(req, res) {res.json(db._query(
});
{ maxPrice: req.params("price"), name: req.session.username }).toArray());
`FOR user IN users FILTER user.name == @name FOR recommendation, action, path IN 3 ANY user has_bought OPTIONS { bfs: true, uniqueVertices: "global" } FILTER path.vertices[2].age <= user.age + 5 AND path.vertices[2].age >= user.age - 5 FILTER recommendation.price < @maxPrice LIMIT 10 RETURN recommendation`,
![Page 42: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/42.jpg)
Does it Scale?
‣ Sharding (Huge Dataset, Write-Scaling) ‣ Collection: distributed across several servers ‣ Distributed by: List of Attributes (default: _key) ‣ Number of Shards immutable ‣ Has to be defined on creation ‣ Can be different for all collections ‣ Suggested: #Servers
30
2
![Page 43: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/43.jpg)
Does it Scale?
‣ Sharding (Huge Dataset, Write-Scaling) ‣ Collection: distributed across several servers ‣ Distributed by: List of Attributes (default: _key) ‣ Number of Shards immutable ‣ Has to be defined on creation ‣ Can be different for all collections ‣ Suggested: #Servers
30
2
‣ Replication (Failover, Read-Scaling) ‣ Shard: can have n Followers (Replicas) ‣ Followers:
‣ do not accept writes ‣ synchronous (identical data) ‣ placed on different machine (if possible)
![Page 44: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/44.jpg)
Speaking of Clusters ...
31
![Page 45: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/45.jpg)
32
![Page 46: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/46.jpg)
33
Marathon
![Page 47: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/47.jpg)
‣ Connects the cluster ‣ Ressource management ‣ Knows which servers are online ‣ Knows which resources they have
34
![Page 48: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/48.jpg)
Marathon
‣ Builds on top of Mesos ‣ Application Monitor ‣ Can start new applications ‣ "Monitors" running applications ‣ If a machine/process dies Marathon restarts it ‣ Can stop applications ➡Can scale up / down running applications within a cluster
‣ Offers available resources to new applications ‣ If Marathon dies it is restarted somewhere else
35
![Page 49: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/49.jpg)
‣ Builds on top of Marathon ‣ "Data-Center-Operating-System" ‣ Offers one-click installers for applications (DC/OS Universe) ‣ Includes Service Discovery ‣ Includes Reverse Proxying
➡ You just run an Application through DC/OS and you can communicate with it without ever knowing any IP address
36
![Page 50: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/50.jpg)
Frameworks
‣ Marathons little helpers ‣ Know details about complete Applications ‣ Communicate with Marathon to order sub-processes ‣ Can describe additional conditions for processes ‣ Like: "Do not run all DB instances on the same Machine"
‣ Can trigger marathon to scale up/down processes
➡ ArangoDB has a Marathon Framework
37
![Page 51: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/51.jpg)
Live Demo ArangoDB on DC/OS
38
![Page 52: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/52.jpg)
Is Mesosphere required?
‣ ArangoDB can run clusters without it ‣ Setup Requires manual effort (can be scripted): ‣ Configure IP addresses ‣ Correct startup ordering
‣ This works: ‣ Automatic Failover (Follower takes over if leader dies) ‣ Rebalancing of shards ‣ Everything inside of ArangoDB
‣ This is based on Mesos: ‣ Complete self healing ‣ Automatic restart of ArangoDBs (on new machines)
➡We suggest you have someone on call
39
![Page 53: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/53.jpg)
Does your data-model scale?
‣ Rule of thumb: "The more complex the query, the less it scales".
‣ Indexed-Attribute lookups: ‣ Scale "infinitely" ‣ Examples ‣ Key/Value ‣ FOR doc IN sharded FILTER doc.name == 'Michael'
‣ Joins: ‣ Each join operation requires one additional round-trip (find left side, than
find right side) ‣ Scale "okayish"
‣ Graphs: ‣ Each search depth potentially requires 2 join-like operations ‣ A single-server needs to hold a large intermediate result ‣ Does not scale too good
40
![Page 54: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/54.jpg)
‣ 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
41
An overview of other features
![Page 55: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/55.jpg)
What about Java?
‣ Basic Driver developed in-house ‣ Tutorial: https://www.arangodb.com/tutorials/tutorial-java/
‣ We are working on a Spring-Data integration
‣ We are very happy to get input on this ‣ Feedback ‣ Feature Requests ‣ Personal Opinion on other Drivers/Integration you worked with ‣ Development
42
![Page 56: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/56.jpg)
Join our growing community
43
.. working on the geo index, the full text search and many APIs: Ruby, Python, PHP, Java, D,
Javascript, ...
![Page 57: Polyglot Persistence & Multi-Model Databases](https://reader033.fdocuments.us/reader033/viewer/2022042706/58731e901a28ab673e8b6f17/html5/thumbnails/57.jpg)
Thank you
‣ Further questions? ‣ Follow us on twitter: @arangodb ‣ Join or community slack: arangodb-community.slack.com ‣ Join or google group: https://groups.google.com/forum/#!forum/arangodb
‣ Follow me on twitter/github: @mchacki ‣ Write me a mail: [email protected]
44