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.
3. NoSQL DBs & Characteristics
‣ non-relational
‣ open-source
‣ cluster friendly
‣ high traffic
‣ schema-less
3
‣ key/value store
‣ document store
‣ column store
‣ graph databases
4. The Multi Model era begins
4
NoSQL World
Documents - JSON
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
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“: "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
5. An e-commerce system in Relational World
5
Sales-History
Shopping-Cart
Recommendations Customer
Product-Catalog
6. 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
8. Benefits & Overhead (Polyglot Persistence)
‣ 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
9. “The Real World of the Database Administrator”
Study by DELL (March 2015)
‣ The key challenge for DBAs is learning new technologies.
9
11. Solution: Multi Model Database
‣ Can natively store several kinds of data models:
‣ Key-value pairs
‣ Documents
‣ Graphs
‣ Delivers query mechanisms for all data models
11
12. Polyglot Persistence Revisited
12
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
14. My four favourite features of
‣ MULTI-MODEL stores graphs and documents
‣ AQL offering joins & traversals
‣ ACID including Multi Collection Transactions
14
‣ FOXX extend the API and adapt it to your needs
15. AQL
15
FOR p IN product
FILTER p.color == "yellow"
FOR d IN GRAPH_DISTANCE_TO("suggestions", p._id,
"customer/alice", {direction: "inbound"})
FILTER d.distance > 1
RETURN p
LIMIT 10
RETURN r
SORT d.distance
Lena
(Customer)
knows
bought
likes
on: 03/2015
Shirt
(Product)
Alice
(Customer)
color: yellow
VERTEX
EDGE
VERTEX
16. Foxx Example
16
FILTER p.color == @color
FOR d IN GRAPH_DISTANCE_TO("suggestion", p._id,
"customer/alice", {direction: "inbound"})
LET r = {distance: d.distance, product: p}
FILTER r.distance > 1
SORT r.distance
LIMIT 10
RETURN r',
controller.get("/recommend/:color", function(req, res) {
res.json(db._query('FOR p IN products
});
{color: req.params("color")}).toArray());
17. ‣ Native mapping of data into
DB
‣ DB optimized
‣ Queries are tailored for
your data format
‣ Focus on writing business
logic
17
‣Data has to be stored
redundantly and has to be
kept in sync
‣Several technologies involved
‣Administration effort is huge
‣One technology involved
Benefits & Overhead (Multi-Model)
18. ‣ 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
18
An overview of other features
19. DCOS integration
19
‣Run distributed databases and
other distributed applications
sharing a single DCOS, like
Mesosphere or Docker Swarm.
‣A DCOS offers services that
simplify the design and
implementation of a distributed
database.
‣ArangoDB's distributed design
lends itself particularly well for
Apache Mesos integration.
‣At the same time we can benefit
from the Mesos infrastructure for
our own failover and convenient
cluster administration.
20. Join our growing community
20
.. working on the geo index, the full text search and
many APIs: Ruby, Python, PHP, Java, D, Javascript, ...
21. Thank you
‣ Further questions?
‣ Write me a mail: ingo@arangodb.com
‣ Join our google group: https://groups.google.com/forum/#!forum/arangodb
21