SlideShare a Scribd company logo
Copyright © ArangoDB Inc. , 2019
An introduction to
multi-model databases and the
native multi-model database ArangoDB
Copyright © ArangoDB Inc. , 2019
My name is Jan!
I am from Cologne, Germany
I work for a database company named ArangoDB...
...on an open-source database also named ArangoDB
Hi, nice to meet you!
Copyright © ArangoDB Inc. , 2019
Databases
market trends
Copyright © ArangoDB Inc. , 2019
Relational relational storage, fixed schema, SQL, transactions
197x – now
"NoSQL" horizontal scaling, high availability, low-latency,
200x – now non-relational storage
but: no complex querying, no transactions!
"NewSQL" fusing scalability and resilience with
201x – now complex querying and transactions
Database trends
Copyright © ArangoDB Inc. , 2019
db-engines.com lists 343 database systems as of January 2019:
We now got: relational databases, key-value stores,
document stores, time-series databases, graph databases,
search engines, object databases, XML databases, RDF stores, ...
Now the database market is fragmented
WTF?!?
Copyright © ArangoDB Inc. , 2019
Which
database to
use for a new
project?
Copyright © ArangoDB Inc. , 2019
●
one obvious solution is to keep on using relational databases
for all tasks
●
this will work if the database schema is relatively fixed
●
for dynamically structured data, or varyingly connected data,
this approach will likely run into problems
●
it will very likely be a problematic approach if horizontal scaling
and availability are required
Solution: keep using relational databases
Copyright © ArangoDB Inc. , 2019
●
"use the right tool(s) for the job"
●
assumption: specialized products are better suited
than generic products
●
for example, why not use (all at the same time):
- an in-memory key-value store for caching,
- a persistent key-value store for user management,
- a relational database for order processing,
- a graph database for recommendations,
- a search engine for fulltext search?
Alternative: "Polyglot persistence"
Copyright © ArangoDB Inc. , 2019
●
Requires learning, administering and maintaining
multiple technologies
●
Needs custom scripts and / or application logic for shipping
data from one system to the other, or for syncing systems
●
Potential atomicity and consistency issues across the
different database systems (i.e. no transactions)
Issues with polyglot persistence
Copyright © ArangoDB Inc. , 2019
Multi-model
databases to
the rescue?
Copyright © ArangoDB Inc. , 2019
●
The main idea behind multi-model databases is to support
different data models in the same database product
●
So that the different data models in a multi-model database
can easily be combined in queries and even transactions
(composability)
What are multi-model databases?
Copyright © ArangoDB Inc. , 2019
●
Having to master and administer only a single technology
●
Being less locked-in to one specific data model and its limitations
●
More flexible in case the requirements change
●
Removing atomicity and consistency issues for syncing different
datastores, and not having to deal with these issues
in the application layer
Multi-model database key benefits
Copyright © ArangoDB Inc. , 2019
Multi-model databases (from Wikipedia)
Copyright © ArangoDB Inc. , 2019
●
Some traditional relational databases recently got
extensions for key-value handling and document storage
●
Strictly speaking, all of them could be called "multi-model"
●
Often the extra data models have been "bolted on top" of
these products, leading to poor support or inefficient
implementations
"Layered multi-model" is also a trend
Copyright © ArangoDB Inc. , 2019
ArangoDB,
the native
multi-model
database
Copyright © ArangoDB Inc. , 2019
ArangoDB is a native multi-model database, with support for
key-values, documents, graphs and (recently added) search
functionality
These data models are composable and can be combined via
AQL, ArangoDB's unified query language
At a glance
Copyright © ArangoDB Inc. , 2019
●
On the highest level, data in ArangoDB is organized in
"databases" and "collections" (think "schemas" and "tables")
●
Collections are used to store "documents" of similar types
●
"Documents" are just JSON objects with arbitrary attributes,
with optional nesting (sub-objects, sub-arrays)
●
There is no fixed schema for documents (any JSON object is valid)
Databases, collections, documents
Copyright © ArangoDB Inc. , 2019
In the easiest case, documents in a collection are homogeneous
(i.e. same attributes and types)
Example use case: product categories
{ "_key" : "books", "title" : "Books" }
{ "_key" : "cam", "title" : "Camera products" }
{ "_key" : "kitchen", "title" : "Kitchen Appliances" }
{ "_key" : "toys", "title" : "Toys & Games" }
Processing such data in AQL queries is as straightforward as with
an SQL query on a relational, fixed-schema table
Homogeneous documents
Copyright © ArangoDB Inc. , 2019
// SELECT c.* FROM categories c WHERE c._key IN ...
FOR c IN categories
FILTER c._key IN [ 'books', 'kitchen' ]
RETURN c
// SELECT c._key, c.title FROM categories c ORDER BY c.title
FOR c IN categories
SORT c.title
RETURN {
_key: c._key,
title: c.title
}
AQL queries – hello world examples
Copyright © ArangoDB Inc. , 2019
In more complex cases, documents in the same collection
are heterogeneous (i.e. attribute names or types differ)
This is often the case when objects have some common attributes,
but there are different special attributes for sub-types
Example use case: product catalogs
Heterogeneous documents
Copyright © ArangoDB Inc. , 2019
{
"_key" : "A053720452",
"category" : "books",
"name" : "Harry Potter and the Cursed Child",
"author" : "Joanne K. Rowling",
"isbn" : "978-0-7515-6535-5",
"published" : 2016
}
{
"_key" : "ZB4061305X34",
"category" : "toys",
"name" : "Nerf N-Strike Elite Mega CycloneShock Blaster",
"upc" : "630509278862",
"colors" : [ "black", "red" ]
}
Heterogeneous documents example
Copyright © ArangoDB Inc. , 2019
ArangoDB is schema-less, meaning optional attributes can be
queried the same way as common attributes:
// no SQL equivalent, because no optional attributes allowed
FOR p IN products
FILTER p.name == @search OR
p.isbn == @search OR
p.upc == @search
RETURN p
The value of non-existing attributes evaluates to null at runtime
Querying heterogeneous documents
Copyright © ArangoDB Inc. , 2019
Like SQL, AQL allows joining data from multiple sources:
// SELECT c.* AS category, p.* AS product FROM categories c,
// products p WHERE p.category = c._key ORDER BY c.title, p.name
FOR c IN categories
FOR p IN products
FILTER p.category == c._key // "category" should be indexed!
SORT c.title, p.name
RETURN {
category: c,
product: p
}
AQL – joins
Copyright © ArangoDB Inc. , 2019
●
Documents can be accessed efficiently by their primary key,
which is automatically indexed in ArangoDB ("_key" attribute)
●
Extra secondary indexes can be created as needed
to support efficient querying by different attributes
●
Index types: hash, skiplist, geo, fulltext
Indexes for more efficient querying
Copyright © ArangoDB Inc. , 2019
// this will return an array of product details per category
// there is no direct SQL equivalent, as this will return a
// nested, variable-length sub-array of products per category
FOR c IN categories
RETURN {
category: c.title,
products: (
FOR p IN products
FILTER p.category == c._key
SORT p.name
RETURN { _key: p._key, name: p.name }
)
}
AQL – subqueries
Copyright © ArangoDB Inc. , 2019
// SELECT s.year, s.product, SUM(c.count) AS count,
// SUM(s.amount) AS amount FROM sales s WHERE s.year
// BETWEEN 2017 AND 2019 GROUP BY s.year, s.product
FOR s IN sales
FILTER s.year >= 2017 AND s.year <= 2019
COLLECT year = s.year,
product = s.product
AGGREGATE count = SUM(s.count),
amount = SUM(s.amount)
RETURN {
year, product: DOCUMENT('products', product), count, amount
}
AQL – aggregation
Copyright © ArangoDB Inc. , 2019
// update all documents which don't have a "lastModified"
// attribute, store the current date in it, and return the _keys
// of the documents updated
FOR p IN products
FILTER !HAS(p, "lastModified")
UPDATE p WITH {
lastModified: DATE_ISO8601(DATE_NOW())
} IN products
RETURN OLD._key
AQL – data modification
Copyright © ArangoDB Inc. , 2019
// delete documents of the specified categories, and return
// all data of the deleted documents
FOR p IN products
FILTER p.category IN [ "toys", "kitchen" ]
REMOVE p IN products RETURN OLD
AQL – data modification
Copyright © ArangoDB Inc. , 2019
●
Geo queries
●
Fulltext indexing and searching
Other AQL features (not shown here)
Copyright © ArangoDB Inc. , 2019
●
ArangoDB also supports the graph data model
●
Graph queries can reveal which documents are directly or
indirectly connected to which other documents, and via
what connections
●
Graphs are often used for data exploration, and to understand
connections in the data
The graph data model
Copyright © ArangoDB Inc. , 2019
●
In graphs, connections between documents are called "edges"
●
In ArangoDB edges are stored in "edge collections"
●
Edges have "_from" and "_to" attributes, which reference the
connected vertices
●
Edges are always directed (_from -> _to), but can also be
queried in opposite order
Edges
Copyright © ArangoDB Inc. , 2019
Let's assume there are some "employees" documents like this:
{ "_key" : "sofia", "_id" : "employees/sofia" }
{ "_key" : "adam", "_id" : "employees/adam" }
{ "_key" : "sarah", "_id" : "employees/sarah" }
{ "_key" : "jon", "_id" : "employees/jon" }
And there is an "isManagerOf" edge collection connecting them:
{ "_from" : "employees/sofia", "_to" : "employees/adam" }
{ "_from" : "employees/sofia", "_to" : "employees/sarah" }
{ "_from" : "employees/sarah", "_to" : "employees/jon" }
...
Edge collection example
Copyright © ArangoDB Inc. , 2019
Graph example, employees graph
Copyright © ArangoDB Inc. , 2019
// find all employees that "sofia" is a direct manager of
FOR emp IN 1..1 OUTBOUND 'employees/sofia' isManagerOf
RETURN emp._key
// find all direct and indirect subordinates of "sofia":
FOR emp IN 1..5 OUTBOUND 'employees/sofia' isManagerOf
RETURN emp._key
AQL graph traversals, examples
Copyright © ArangoDB Inc. , 2019
// find employees that "olaf" is indirectly connected to (level 2)
FOR emp IN 2..2 ANY 'employees/olaf' isManagerOf
RETURN emp._key
// find all line managers of employee "olaf", calculate distance
FOR emp, edge, path IN 1..5 INBOUND 'employees/olaf'
isManagerOf
RETURN {
who: emp._key,
level: LENGTH(path.edges)
}
AQL graph traversals, more examples
Copyright © ArangoDB Inc. , 2019
●
Organizational structures
●
Social networks (friends, friends of friends)
●
Recommendation and prediction engines
●
Product component planning and assessment
●
Network and infrastructure assessment
●
Fraud detection
Some graph use cases
Copyright © ArangoDB Inc. , 2019
●
Graphs can also consist of many different collections
●
While traversing the graph, it is also possible to filter on
edge attributes and exclude unwanted edges or paths
●
Graphs can contain cycles, so it is possible to stop searching
already-visited documents and edges
●
Shortest-path queries are also supported
Advanced graph querying
Copyright © ArangoDB Inc. , 2019
Deployment
options
Copyright © ArangoDB Inc. , 2019
●
Single server
●
Active failover: 2+ single servers with asynchronous replication
and automatic failover
●
Cluster: multiple query processing and storage nodes,
horizontal write scaling and resilience
Deployment modes
Copyright © ArangoDB Inc. , 2019
●
Linux, with 64 bit OS
●
Windows 10, Windows 7 SP1, Windows server, with 64 bit OS
●
Mac OS, Sierra and newer
●
Kubernetes (including Google GKE, Amazon EKS, Pivotal PKS)
●
Docker
Supported platforms
Copyright © ArangoDB Inc. , 2019
ArangoDB clusters running on ARM64
Copyright © ArangoDB Inc. , 2019
Bonus
features
Copyright © ArangoDB Inc. , 2019
Administration via web interface
Copyright © ArangoDB Inc. , 2019
Built-in graph viewer
Copyright © ArangoDB Inc. , 2019
●
"Smart graphs" (colocating of documents with all their
outgoing edges on the same physical server)
●
Datacenter-to-datacenter (DC2DC) replication
●
Encryption at rest, encrypted backups
●
LDAP integration for user management
●
Support subscription with SLAs
Additional enterprise edition features
Copyright © ArangoDB Inc. , 2019
ArangoDB Foxx,
for exposing
data via REST
APIs
Copyright © ArangoDB Inc. , 2019
●
Combine your data with an API and you have a microservice!
●
ArangoDB comes with Foxx, a built-in framework
for easily exposing dedicated database data via REST APIs
●
The REST API code is written using JavaScript,
which runs inside the ArangoDB server, close to the data
Foxx – built-in microservice framework
Copyright © ArangoDB Inc. , 2019
// endpoint: HTTP GET /managersOf/:employee
router.get("/managersOf/:employee", function (req, res) {
let query = `FOR emp, edge, path IN 1..5 INBOUND
CONCAT('employees/', @employee) isManagerOf
RETURN { who: emp._key, level: LENGTH(path.edges) }' `;
let result = db._query(query, {
employee: req.param("employee") // use path parameter
}).toArray();
res.json(result); // return JSON result to caller
});
Foxx example, custom API code
Copyright © ArangoDB Inc. , 2019
●
It is easy to add input parameter validation and sanitation
●
API documentation facility is already included in the framework
●
API documentation can be made available for humans
(via Swagger UI) and client applications as a service description
JSON file
Foxx – built-in microservice framework
Copyright © ArangoDB Inc. , 2019
Adding the below code to the existing route adds simple validation
for the input parameter and also API documentation:
router.get("/managersOf/:employee", function (req, res) {
... // previous code here
})
.pathParam("employee", joi.string().required(), "employee name")
.summary("returns managers of the employee")
.response(200, 'will return a list of the managers')
.error(404, 'employee has no managers');
Example with input validation and docs
Copyright © ArangoDB Inc. , 2019
●
Data validation, sanitation and transformation
●
Keeping things private by filtering data and running projections
before returning it
●
Complex permissioning based on database data or queries
●
Eliminating network hops by bundling multiple database queries
in a single server-side REST API method
Foxx – use cases
Copyright © ArangoDB Inc. , 2019
●
ArangoDB is a free and open-source native multi-model database
●
Provides support for key-values, documents, graphs
●
Search functionality has been recently added and will be extended
●
Different data models can be used flexibly
●
AQL query language can be used for rich querying, combining all
data models
●
Various deployment modes, including cluster setups
Summary
Copyright © ArangoDB Inc. , 2019
●
Website: https://www.arangodb.com/
●
Slack: https://slack.arangodb.com/
●
Github: arangodb/arangodb
●
Twitter: @arangodb
●
Stack Overflow: #arangodb
Getting in touch

More Related Content

PDF
ArangoML Pipeline Cloud - Managed Machine Learning Metadata
PDF
Webinar: How native multi model works in ArangoDB
PPTX
SAP BW - Info cube
PDF
IBM THINK 2019 - Self-Service Cloud Data Management with SQL
PPTX
SharePoint Metadata and Search Refiners SPSUTAH2013 Jan 2013
PDF
How To Use Sharepoint Metadata
PDF
IBM Cognos tutorial - ABC LEARN
PPT
Business Intelligence
ArangoML Pipeline Cloud - Managed Machine Learning Metadata
Webinar: How native multi model works in ArangoDB
SAP BW - Info cube
IBM THINK 2019 - Self-Service Cloud Data Management with SQL
SharePoint Metadata and Search Refiners SPSUTAH2013 Jan 2013
How To Use Sharepoint Metadata
IBM Cognos tutorial - ABC LEARN
Business Intelligence

What's hot (10)

PPTX
Apache Hive
PDF
Oslo bekk2014
PDF
Database collection flowchart
PPTX
SAP BO Web Intelligence Basics
PPTX
SAP BW - Data store objects
PDF
Sap business Objects certification note paper1
PPTX
asp.net data controls
PPTX
Data Analytics with MongoDB - Jane Fine
PPTX
Apache Hadoop Hive
PPTX
Arches Getty Brownbag Talk
Apache Hive
Oslo bekk2014
Database collection flowchart
SAP BO Web Intelligence Basics
SAP BW - Data store objects
Sap business Objects certification note paper1
asp.net data controls
Data Analytics with MongoDB - Jane Fine
Apache Hadoop Hive
Arches Getty Brownbag Talk
Ad

Similar to An introduction to multi-model databases (20)

PDF
ArangoDB – A different approach to NoSQL
PDF
Oslo baksia2014
PDF
Is multi-model the future of NoSQL?
PDF
Running complex data queries in a distributed system
PPT
MongoDB - An Agile NoSQL Database
ODP
Product catalog using MongoDB
PPTX
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
PPTX
Module 2.3 Document Databases in NoSQL Systems
PDF
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
PDF
An E-commerce App in action built on top of a Multi-model Database
PPT
No SQL and MongoDB - Hyderabad Scalability Meetup
PDF
Artigo no sql x relational
PDF
Multi-model databases and node.js
PDF
MongoDB classes 2019
PDF
Bigtable osdi06
PDF
PDF
PDF
Streaming Analytics Unit 5 notes for engineers
ODP
Doc store
PPTX
Introduction to MongoDB
ArangoDB – A different approach to NoSQL
Oslo baksia2014
Is multi-model the future of NoSQL?
Running complex data queries in a distributed system
MongoDB - An Agile NoSQL Database
Product catalog using MongoDB
3.Implementation with NOSQL databases Document Databases (Mongodb).pptx
Module 2.3 Document Databases in NoSQL Systems
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
An E-commerce App in action built on top of a Multi-model Database
No SQL and MongoDB - Hyderabad Scalability Meetup
Artigo no sql x relational
Multi-model databases and node.js
MongoDB classes 2019
Bigtable osdi06
Streaming Analytics Unit 5 notes for engineers
Doc store
Introduction to MongoDB
Ad

Recently uploaded (20)

PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
Lecture1 pattern recognition............
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
Supervised vs unsupervised machine learning algorithms
PPT
ISS -ESG Data flows What is ESG and HowHow
PDF
Business Analytics and business intelligence.pdf
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
Introduction to machine learning and Linear Models
PDF
Foundation of Data Science unit number two notes
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
Database Infoormation System (DBIS).pptx
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
Data_Analytics_and_PowerBI_Presentation.pptx
Lecture1 pattern recognition............
Introduction to Knowledge Engineering Part 1
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Supervised vs unsupervised machine learning algorithms
ISS -ESG Data flows What is ESG and HowHow
Business Analytics and business intelligence.pdf
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Introduction to machine learning and Linear Models
Foundation of Data Science unit number two notes
Clinical guidelines as a resource for EBP(1).pdf
Database Infoormation System (DBIS).pptx
Miokarditis (Inflamasi pada Otot Jantung)
STUDY DESIGN details- Lt Col Maksud (21).pptx
climate analysis of Dhaka ,Banglades.pptx
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Business Ppt On Nestle.pptx huunnnhhgfvu

An introduction to multi-model databases

  • 1. Copyright © ArangoDB Inc. , 2019 An introduction to multi-model databases and the native multi-model database ArangoDB
  • 2. Copyright © ArangoDB Inc. , 2019 My name is Jan! I am from Cologne, Germany I work for a database company named ArangoDB... ...on an open-source database also named ArangoDB Hi, nice to meet you!
  • 3. Copyright © ArangoDB Inc. , 2019 Databases market trends
  • 4. Copyright © ArangoDB Inc. , 2019 Relational relational storage, fixed schema, SQL, transactions 197x – now "NoSQL" horizontal scaling, high availability, low-latency, 200x – now non-relational storage but: no complex querying, no transactions! "NewSQL" fusing scalability and resilience with 201x – now complex querying and transactions Database trends
  • 5. Copyright © ArangoDB Inc. , 2019 db-engines.com lists 343 database systems as of January 2019: We now got: relational databases, key-value stores, document stores, time-series databases, graph databases, search engines, object databases, XML databases, RDF stores, ... Now the database market is fragmented WTF?!?
  • 6. Copyright © ArangoDB Inc. , 2019 Which database to use for a new project?
  • 7. Copyright © ArangoDB Inc. , 2019 ● one obvious solution is to keep on using relational databases for all tasks ● this will work if the database schema is relatively fixed ● for dynamically structured data, or varyingly connected data, this approach will likely run into problems ● it will very likely be a problematic approach if horizontal scaling and availability are required Solution: keep using relational databases
  • 8. Copyright © ArangoDB Inc. , 2019 ● "use the right tool(s) for the job" ● assumption: specialized products are better suited than generic products ● for example, why not use (all at the same time): - an in-memory key-value store for caching, - a persistent key-value store for user management, - a relational database for order processing, - a graph database for recommendations, - a search engine for fulltext search? Alternative: "Polyglot persistence"
  • 9. Copyright © ArangoDB Inc. , 2019 ● Requires learning, administering and maintaining multiple technologies ● Needs custom scripts and / or application logic for shipping data from one system to the other, or for syncing systems ● Potential atomicity and consistency issues across the different database systems (i.e. no transactions) Issues with polyglot persistence
  • 10. Copyright © ArangoDB Inc. , 2019 Multi-model databases to the rescue?
  • 11. Copyright © ArangoDB Inc. , 2019 ● The main idea behind multi-model databases is to support different data models in the same database product ● So that the different data models in a multi-model database can easily be combined in queries and even transactions (composability) What are multi-model databases?
  • 12. Copyright © ArangoDB Inc. , 2019 ● Having to master and administer only a single technology ● Being less locked-in to one specific data model and its limitations ● More flexible in case the requirements change ● Removing atomicity and consistency issues for syncing different datastores, and not having to deal with these issues in the application layer Multi-model database key benefits
  • 13. Copyright © ArangoDB Inc. , 2019 Multi-model databases (from Wikipedia)
  • 14. Copyright © ArangoDB Inc. , 2019 ● Some traditional relational databases recently got extensions for key-value handling and document storage ● Strictly speaking, all of them could be called "multi-model" ● Often the extra data models have been "bolted on top" of these products, leading to poor support or inefficient implementations "Layered multi-model" is also a trend
  • 15. Copyright © ArangoDB Inc. , 2019 ArangoDB, the native multi-model database
  • 16. Copyright © ArangoDB Inc. , 2019 ArangoDB is a native multi-model database, with support for key-values, documents, graphs and (recently added) search functionality These data models are composable and can be combined via AQL, ArangoDB's unified query language At a glance
  • 17. Copyright © ArangoDB Inc. , 2019 ● On the highest level, data in ArangoDB is organized in "databases" and "collections" (think "schemas" and "tables") ● Collections are used to store "documents" of similar types ● "Documents" are just JSON objects with arbitrary attributes, with optional nesting (sub-objects, sub-arrays) ● There is no fixed schema for documents (any JSON object is valid) Databases, collections, documents
  • 18. Copyright © ArangoDB Inc. , 2019 In the easiest case, documents in a collection are homogeneous (i.e. same attributes and types) Example use case: product categories { "_key" : "books", "title" : "Books" } { "_key" : "cam", "title" : "Camera products" } { "_key" : "kitchen", "title" : "Kitchen Appliances" } { "_key" : "toys", "title" : "Toys & Games" } Processing such data in AQL queries is as straightforward as with an SQL query on a relational, fixed-schema table Homogeneous documents
  • 19. Copyright © ArangoDB Inc. , 2019 // SELECT c.* FROM categories c WHERE c._key IN ... FOR c IN categories FILTER c._key IN [ 'books', 'kitchen' ] RETURN c // SELECT c._key, c.title FROM categories c ORDER BY c.title FOR c IN categories SORT c.title RETURN { _key: c._key, title: c.title } AQL queries – hello world examples
  • 20. Copyright © ArangoDB Inc. , 2019 In more complex cases, documents in the same collection are heterogeneous (i.e. attribute names or types differ) This is often the case when objects have some common attributes, but there are different special attributes for sub-types Example use case: product catalogs Heterogeneous documents
  • 21. Copyright © ArangoDB Inc. , 2019 { "_key" : "A053720452", "category" : "books", "name" : "Harry Potter and the Cursed Child", "author" : "Joanne K. Rowling", "isbn" : "978-0-7515-6535-5", "published" : 2016 } { "_key" : "ZB4061305X34", "category" : "toys", "name" : "Nerf N-Strike Elite Mega CycloneShock Blaster", "upc" : "630509278862", "colors" : [ "black", "red" ] } Heterogeneous documents example
  • 22. Copyright © ArangoDB Inc. , 2019 ArangoDB is schema-less, meaning optional attributes can be queried the same way as common attributes: // no SQL equivalent, because no optional attributes allowed FOR p IN products FILTER p.name == @search OR p.isbn == @search OR p.upc == @search RETURN p The value of non-existing attributes evaluates to null at runtime Querying heterogeneous documents
  • 23. Copyright © ArangoDB Inc. , 2019 Like SQL, AQL allows joining data from multiple sources: // SELECT c.* AS category, p.* AS product FROM categories c, // products p WHERE p.category = c._key ORDER BY c.title, p.name FOR c IN categories FOR p IN products FILTER p.category == c._key // "category" should be indexed! SORT c.title, p.name RETURN { category: c, product: p } AQL – joins
  • 24. Copyright © ArangoDB Inc. , 2019 ● Documents can be accessed efficiently by their primary key, which is automatically indexed in ArangoDB ("_key" attribute) ● Extra secondary indexes can be created as needed to support efficient querying by different attributes ● Index types: hash, skiplist, geo, fulltext Indexes for more efficient querying
  • 25. Copyright © ArangoDB Inc. , 2019 // this will return an array of product details per category // there is no direct SQL equivalent, as this will return a // nested, variable-length sub-array of products per category FOR c IN categories RETURN { category: c.title, products: ( FOR p IN products FILTER p.category == c._key SORT p.name RETURN { _key: p._key, name: p.name } ) } AQL – subqueries
  • 26. Copyright © ArangoDB Inc. , 2019 // SELECT s.year, s.product, SUM(c.count) AS count, // SUM(s.amount) AS amount FROM sales s WHERE s.year // BETWEEN 2017 AND 2019 GROUP BY s.year, s.product FOR s IN sales FILTER s.year >= 2017 AND s.year <= 2019 COLLECT year = s.year, product = s.product AGGREGATE count = SUM(s.count), amount = SUM(s.amount) RETURN { year, product: DOCUMENT('products', product), count, amount } AQL – aggregation
  • 27. Copyright © ArangoDB Inc. , 2019 // update all documents which don't have a "lastModified" // attribute, store the current date in it, and return the _keys // of the documents updated FOR p IN products FILTER !HAS(p, "lastModified") UPDATE p WITH { lastModified: DATE_ISO8601(DATE_NOW()) } IN products RETURN OLD._key AQL – data modification
  • 28. Copyright © ArangoDB Inc. , 2019 // delete documents of the specified categories, and return // all data of the deleted documents FOR p IN products FILTER p.category IN [ "toys", "kitchen" ] REMOVE p IN products RETURN OLD AQL – data modification
  • 29. Copyright © ArangoDB Inc. , 2019 ● Geo queries ● Fulltext indexing and searching Other AQL features (not shown here)
  • 30. Copyright © ArangoDB Inc. , 2019 ● ArangoDB also supports the graph data model ● Graph queries can reveal which documents are directly or indirectly connected to which other documents, and via what connections ● Graphs are often used for data exploration, and to understand connections in the data The graph data model
  • 31. Copyright © ArangoDB Inc. , 2019 ● In graphs, connections between documents are called "edges" ● In ArangoDB edges are stored in "edge collections" ● Edges have "_from" and "_to" attributes, which reference the connected vertices ● Edges are always directed (_from -> _to), but can also be queried in opposite order Edges
  • 32. Copyright © ArangoDB Inc. , 2019 Let's assume there are some "employees" documents like this: { "_key" : "sofia", "_id" : "employees/sofia" } { "_key" : "adam", "_id" : "employees/adam" } { "_key" : "sarah", "_id" : "employees/sarah" } { "_key" : "jon", "_id" : "employees/jon" } And there is an "isManagerOf" edge collection connecting them: { "_from" : "employees/sofia", "_to" : "employees/adam" } { "_from" : "employees/sofia", "_to" : "employees/sarah" } { "_from" : "employees/sarah", "_to" : "employees/jon" } ... Edge collection example
  • 33. Copyright © ArangoDB Inc. , 2019 Graph example, employees graph
  • 34. Copyright © ArangoDB Inc. , 2019 // find all employees that "sofia" is a direct manager of FOR emp IN 1..1 OUTBOUND 'employees/sofia' isManagerOf RETURN emp._key // find all direct and indirect subordinates of "sofia": FOR emp IN 1..5 OUTBOUND 'employees/sofia' isManagerOf RETURN emp._key AQL graph traversals, examples
  • 35. Copyright © ArangoDB Inc. , 2019 // find employees that "olaf" is indirectly connected to (level 2) FOR emp IN 2..2 ANY 'employees/olaf' isManagerOf RETURN emp._key // find all line managers of employee "olaf", calculate distance FOR emp, edge, path IN 1..5 INBOUND 'employees/olaf' isManagerOf RETURN { who: emp._key, level: LENGTH(path.edges) } AQL graph traversals, more examples
  • 36. Copyright © ArangoDB Inc. , 2019 ● Organizational structures ● Social networks (friends, friends of friends) ● Recommendation and prediction engines ● Product component planning and assessment ● Network and infrastructure assessment ● Fraud detection Some graph use cases
  • 37. Copyright © ArangoDB Inc. , 2019 ● Graphs can also consist of many different collections ● While traversing the graph, it is also possible to filter on edge attributes and exclude unwanted edges or paths ● Graphs can contain cycles, so it is possible to stop searching already-visited documents and edges ● Shortest-path queries are also supported Advanced graph querying
  • 38. Copyright © ArangoDB Inc. , 2019 Deployment options
  • 39. Copyright © ArangoDB Inc. , 2019 ● Single server ● Active failover: 2+ single servers with asynchronous replication and automatic failover ● Cluster: multiple query processing and storage nodes, horizontal write scaling and resilience Deployment modes
  • 40. Copyright © ArangoDB Inc. , 2019 ● Linux, with 64 bit OS ● Windows 10, Windows 7 SP1, Windows server, with 64 bit OS ● Mac OS, Sierra and newer ● Kubernetes (including Google GKE, Amazon EKS, Pivotal PKS) ● Docker Supported platforms
  • 41. Copyright © ArangoDB Inc. , 2019 ArangoDB clusters running on ARM64
  • 42. Copyright © ArangoDB Inc. , 2019 Bonus features
  • 43. Copyright © ArangoDB Inc. , 2019 Administration via web interface
  • 44. Copyright © ArangoDB Inc. , 2019 Built-in graph viewer
  • 45. Copyright © ArangoDB Inc. , 2019 ● "Smart graphs" (colocating of documents with all their outgoing edges on the same physical server) ● Datacenter-to-datacenter (DC2DC) replication ● Encryption at rest, encrypted backups ● LDAP integration for user management ● Support subscription with SLAs Additional enterprise edition features
  • 46. Copyright © ArangoDB Inc. , 2019 ArangoDB Foxx, for exposing data via REST APIs
  • 47. Copyright © ArangoDB Inc. , 2019 ● Combine your data with an API and you have a microservice! ● ArangoDB comes with Foxx, a built-in framework for easily exposing dedicated database data via REST APIs ● The REST API code is written using JavaScript, which runs inside the ArangoDB server, close to the data Foxx – built-in microservice framework
  • 48. Copyright © ArangoDB Inc. , 2019 // endpoint: HTTP GET /managersOf/:employee router.get("/managersOf/:employee", function (req, res) { let query = `FOR emp, edge, path IN 1..5 INBOUND CONCAT('employees/', @employee) isManagerOf RETURN { who: emp._key, level: LENGTH(path.edges) }' `; let result = db._query(query, { employee: req.param("employee") // use path parameter }).toArray(); res.json(result); // return JSON result to caller }); Foxx example, custom API code
  • 49. Copyright © ArangoDB Inc. , 2019 ● It is easy to add input parameter validation and sanitation ● API documentation facility is already included in the framework ● API documentation can be made available for humans (via Swagger UI) and client applications as a service description JSON file Foxx – built-in microservice framework
  • 50. Copyright © ArangoDB Inc. , 2019 Adding the below code to the existing route adds simple validation for the input parameter and also API documentation: router.get("/managersOf/:employee", function (req, res) { ... // previous code here }) .pathParam("employee", joi.string().required(), "employee name") .summary("returns managers of the employee") .response(200, 'will return a list of the managers') .error(404, 'employee has no managers'); Example with input validation and docs
  • 51. Copyright © ArangoDB Inc. , 2019 ● Data validation, sanitation and transformation ● Keeping things private by filtering data and running projections before returning it ● Complex permissioning based on database data or queries ● Eliminating network hops by bundling multiple database queries in a single server-side REST API method Foxx – use cases
  • 52. Copyright © ArangoDB Inc. , 2019 ● ArangoDB is a free and open-source native multi-model database ● Provides support for key-values, documents, graphs ● Search functionality has been recently added and will be extended ● Different data models can be used flexibly ● AQL query language can be used for rich querying, combining all data models ● Various deployment modes, including cluster setups Summary
  • 53. Copyright © ArangoDB Inc. , 2019 ● Website: https://www.arangodb.com/ ● Slack: https://slack.arangodb.com/ ● Github: arangodb/arangodb ● Twitter: @arangodb ● Stack Overflow: #arangodb Getting in touch