SlideShare a Scribd company logo
1 of 42
Download to read offline
© 2013 triAGENS GmbH | 2013-06-18
Query Languages
for Document Stores
2013-06-18
Jan Steemann
© 2013 triAGENS GmbH | 2013-06-18
me
 I'm a software developer
 working at triAGENS GmbH, CGN
 on - a document store
© 2013 triAGENS GmbH | 2013-06-18
Documents
© 2013 triAGENS GmbH | 2013-06-18
Documents
 documents are self-contained,
aggregate data structures...
 ...consisting of named and typed attributes,
which can be nested / hierarchical
 documents can be used to model complex
business objects
© 2013 triAGENS GmbH | 2013-06-18
Example order document
{ 
  "id": "abc­100­22", 
  "date": "2013­04­26" 
  "customer": {
    "id": "c­199­023",
    "name": "acme corp."
  },
  "items": [ { 
      "id": "p­123",
      "quantity": 1,
      "price": 25.13
  } ]
}  
© 2013 triAGENS GmbH | 2013-06-18
Document stores
 document stores are databases
specialised in handling documents
 they've been around for a while
 got really popular with the NoSQL buzz
(CouchDB, MongoDB, ...)
© 2013 triAGENS GmbH | 2013-06-18
Why use
Document
Stores?
© 2013 triAGENS GmbH | 2013-06-18
Saving programming language data
 document stores allow saving a
programming language object as a whole
 your programming language object
becomes a document in the database,
without the need for much transformation
 compare this to saving data in a relational
database...
© 2013 triAGENS GmbH | 2013-06-18
Persistence the relational way
orders
id date
1 2013-04-20
2 2013-04-21
3 2013-04-21
4 2013-04-22
customers
customer
c1
c2
c1
c3
id name
c1
c2
c3
acme corp.
sample.com
abc co.
orderitems
1
order item
1
price quantity
23.25 1
© 2013 triAGENS GmbH | 2013-06-18
Benefits of document stores
 no impedance mismatch,
no complex object-relational mapping,
no normalisation requirements
 querying documents is often easier and
faster than querying highly normalised
relational data
© 2013 triAGENS GmbH | 2013-06-18
Schema-less
 in document stores, there is no "table"-
schema as in the relational world
 each document can have different attributes
 there is no such thing as ALTER TABLE
 that's why document stores are called
schema-less or schema-free
© 2013 triAGENS GmbH | 2013-06-18
Querying
Document
Stores
© 2013 triAGENS GmbH | 2013-06-18
Querying by document id is easy
 every document store allows querying a
single document at a time
 accessing documents by their unique ids is
almost always dead-simple
© 2013 triAGENS GmbH | 2013-06-18
Complex queries?
 what if you want to run complex queries (e.g.
projections, filters, aggregations,
transformations, joins, ...)??
 let's check the available options in some of
the popular document stores
© 2013 triAGENS GmbH | 2013-06-18
CouchDB: map-reduce
 querying by something else than document
key / id requires writing a view
 views are JavaScript functions that are
stored inside the database
 views are populated by incremental map-
reduce
© 2013 triAGENS GmbH | 2013-06-18
map-reduce
 the map function is applied on each document
(that changed)
 map can filter out non-matching documents
 or emit modified or unmodified versions of them
 emitted documents can optionally be passed into
a reduce function
 reduce is called with groups of similar
documents and can thus perform aggregation
© 2013 triAGENS GmbH | 2013-06-18
CouchDB map-reduce example
map = function (doc) {
  var i, n = doc.orderItems.length;
  for (i = 0; i < n; ++i) {
    emit(doc.orderItems[i], 1);
  }
};
reduce = function (keys, values, rereduce) {
  if (rereduce) {
    return sum(values);
  }
  return values.length;
};
© 2013 triAGENS GmbH | 2013-06-18
map-reduce
 map-reduce is generic and powerful
 provides a programming language
 need to create views for everything that is
queried
 access to a single "table" at a time (no
cross-"table" views)
 a bit clumsy for ad-hoc exploratory queries
© 2013 triAGENS GmbH | 2013-06-18
MongoDB: find()
 ad-hoc queries in MongoDB are much easier
 can directly apply filters on collections,
allowing to find specific documents easily:
mongo> db.orders.find({ 
  "customer": { 
    "id": "c1",
    "name": "acme corp."
  }
});
© 2013 triAGENS GmbH | 2013-06-18
MongoDB: complex filters
 can filter on any document attribute or
sub-attribute
 indexes will automatically be used if present
 nesting filters allows complex queries
 quite flexible and powerful, but tends to be
hard to use and read for more complex
queries
© 2013 triAGENS GmbH | 2013-06-18
MongoDB: complex filtering
mongo> db.users.find({ 
  "$or": [ 
    { 
      "active": true 
    }, 
    { 
      "age": { 
        "$gte": 40 
      } 
    } 
  ]
});
© 2013 triAGENS GmbH | 2013-06-18
MongoDB: more options
 can also use JavaScript functions for filtering,
or JavaScript map-reduce
 several aggregation functions are also
provided
 neither option allows running cross-"table"
queries
© 2013 triAGENS GmbH | 2013-06-18
Why not use a
Query
Language?
© 2013 triAGENS GmbH | 2013-06-18
Query languages
 a good query language should
 allow writing both simple and complex
queries, without having to switch the
methodology
 provide the required features for filtering,
aggregation, joining etc.
 hide the database internals
© 2013 triAGENS GmbH | 2013-06-18
SQL
 in the relational world, there is one accepted
general-purpose query language: SQL
 it is quite well-known and mature:
 35+ years of experience
 many developers and established tools
around it
 standardised (but mind the "dialects"!)
© 2013 triAGENS GmbH | 2013-06-18
SQL in document stores?
 SQL is good at handling relational data
 not good at handling multi-valued or
hierchical attributes, which are common in
documents
 (too) powerful: SQL provides features many
document stores intentionally lack (e.g. joins,
transactions)
 SQL has not been adopted by document
stores yet
© 2013 triAGENS GmbH | 2013-06-18
Query
Languages
for Document
Stores
© 2013 triAGENS GmbH | 2013-06-18
XQuery?
 XQuery is a query and programming
language
 targeted mainly at processing XML data
 can process hierarchical data
 very powerful and extensible
 W3C recommendation
© 2013 triAGENS GmbH | 2013-06-18
XQuery
 XQuery has found most adoption in the area
of XML processing
 today people want to use JSON, not XML
 XQuery not available in popular document
stores
© 2013 triAGENS GmbH | 2013-06-18
ArangoDB Query Language (AQL)
 ArangoDB provides AQL, a query language
made for JSON document processing
 it allows running complex queries on
documents, including joins and aggregation
 language syntax was inspired by XQuery and
provides similar concepts such as
FOR, LET, RETURN, ...
 the language integrates JSON "naturally"
© 2013 triAGENS GmbH | 2013-06-18
AQL example
FOR order IN orders
  FILTER order.status == "processed"
  LET itemsValue = SUM((
    FOR item IN order.items
      FILTER item.status == "confirmed"
      RETURN item.price * item.quantity
  ))
  FILTER itemsValue >= 500
  RETURN {
    "items"      : order.items,
    "itemsValue" : itemsValue,
    "itemsCount" : LENGTH(order.items)
  }
© 2013 triAGENS GmbH | 2013-06-18
AQL: some features
 queries can combine data from multiple
"tables"
 this allows joins using any document
attributes or sub-attributes
 indexes will be used if present
© 2013 triAGENS GmbH | 2013-06-18
AQL: join example
FOR user IN users
  FILTER user.id == 1234
  RETURN {
    "user"  : user,
    "posts" : (FOR post IN blogPosts
      FILTER post.userId == user.id &&
             post.date >= '2013­06­13'          
  
      RETURN post
    )
  }
© 2013 triAGENS GmbH | 2013-06-18
AQL: additional features
 AQL provides basic functionality to query
graphs, too
 the language can be extended with user-
defined JavaScript functions
© 2013 triAGENS GmbH | 2013-06-18
JSONiq
 JSONiq is a data processing and query
language for handling JSON data
 it is based on XQuery, thus provides the same
FLWOR expressions: FOR, LET, WHERE,
ORDER, ...
 JSON is integrated "naturally"
 most of the XML handling is removed
© 2013 triAGENS GmbH | 2013-06-18
JSONiq: example
for $order in collection("orders")
  where $order.customer.id eq "abc­123"
  return {
    customer : $order.customer,
    items    : $order.items
  }
© 2013 triAGENS GmbH | 2013-06-18
JSONiq: join example
for $post in collection("posts")
  let $postId := $post.id
  for $comment in collection("comments")
    where $comment.postId eq $postId
    group by $postId
    order by count($comment) descending
    return {
      id       : $postId,
      comments : count($comment)
    }
© 2013 triAGENS GmbH | 2013-06-18
JSONiq
 JSONiq is a generic, database-agnostic
language
 it can be extended with user-defined XQuery
functions
 JSONiq is currently not implemented inside
any document database...
© 2013 triAGENS GmbH | 2013-06-18
JSONiq
 ...but it can be used via a service (at 28.io)
 the service provides the JSONiq query
language and implements functionality not
provided by a specific database
 such features are implemented client-side,
e.g. joins for MongoDB
© 2013 triAGENS GmbH | 2013-06-18
Summary
© 2013 triAGENS GmbH | 2013-06-18
Summary
 today's document stores provide different,
proprietary mechanisms for querying data
 there is currently no standard query
mechanism for document stores as there is
in the relational world (SQL)
© 2013 triAGENS GmbH | 2013-06-18
Summary
 you CAN use query languages in document
stores today, e.g. AQL and JSONiq
 if you like the idea, give them a try, provide
feedback and contribute!

More Related Content

What's hot

NoSQL and MapReduce
NoSQL and MapReduceNoSQL and MapReduce
NoSQL and MapReduceJ Singh
 
Introduction to ArangoDB (nosql matters Barcelona 2012)
Introduction to ArangoDB (nosql matters Barcelona 2012)Introduction to ArangoDB (nosql matters Barcelona 2012)
Introduction to ArangoDB (nosql matters Barcelona 2012)ArangoDB Database
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2Fabio Fumarola
 
guacamole: an Object Document Mapper for ArangoDB
guacamole: an Object Document Mapper for ArangoDBguacamole: an Object Document Mapper for ArangoDB
guacamole: an Object Document Mapper for ArangoDBMax Neunhöffer
 
FOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDBFOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDBArangoDB Database
 
Multi model-databases 29-10-2014 LJC
Multi model-databases 29-10-2014 LJCMulti model-databases 29-10-2014 LJC
Multi model-databases 29-10-2014 LJCArangoDB Database
 
ArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB 3.7 Roadmap: Performance at ScaleArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB 3.7 Roadmap: Performance at ScaleArangoDB Database
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless DatabasesDan Gunter
 
Object Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQLObject Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQLShahriar Hyder
 
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...NoSQLmatters
 
Assignment_4
Assignment_4Assignment_4
Assignment_4Kirti J
 
Introduction à DocumentDB
Introduction à DocumentDBIntroduction à DocumentDB
Introduction à DocumentDBMSDEVMTL
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingDATAVERSITY
 

What's hot (20)

NoSQL and MapReduce
NoSQL and MapReduceNoSQL and MapReduce
NoSQL and MapReduce
 
Introduction to ArangoDB (nosql matters Barcelona 2012)
Introduction to ArangoDB (nosql matters Barcelona 2012)Introduction to ArangoDB (nosql matters Barcelona 2012)
Introduction to ArangoDB (nosql matters Barcelona 2012)
 
Multi model-databases
Multi model-databasesMulti model-databases
Multi model-databases
 
5 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/25 Data Modeling for NoSQL 1/2
5 Data Modeling for NoSQL 1/2
 
guacamole: an Object Document Mapper for ArangoDB
guacamole: an Object Document Mapper for ArangoDBguacamole: an Object Document Mapper for ArangoDB
guacamole: an Object Document Mapper for ArangoDB
 
FOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDBFOXX - a Javascript application framework on top of ArangoDB
FOXX - a Javascript application framework on top of ArangoDB
 
Multi model-databases 29-10-2014 LJC
Multi model-databases 29-10-2014 LJCMulti model-databases 29-10-2014 LJC
Multi model-databases 29-10-2014 LJC
 
ArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB 3.7 Roadmap: Performance at ScaleArangoDB 3.7 Roadmap: Performance at Scale
ArangoDB 3.7 Roadmap: Performance at Scale
 
Oslo bekk2014
Oslo bekk2014Oslo bekk2014
Oslo bekk2014
 
Ssn0020 ssis 2012 for beginners
Ssn0020   ssis 2012 for beginnersSsn0020   ssis 2012 for beginners
Ssn0020 ssis 2012 for beginners
 
ArangoDB
ArangoDBArangoDB
ArangoDB
 
Nosql
NosqlNosql
Nosql
 
Nosql
NosqlNosql
Nosql
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless Databases
 
Object Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQLObject Relational Mapping with LINQ To SQL
Object Relational Mapping with LINQ To SQL
 
Deep Dive on ArangoDB
Deep Dive on ArangoDBDeep Dive on ArangoDB
Deep Dive on ArangoDB
 
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
 
Assignment_4
Assignment_4Assignment_4
Assignment_4
 
Introduction à DocumentDB
Introduction à DocumentDBIntroduction à DocumentDB
Introduction à DocumentDB
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data Modeling
 

Viewers also liked

Introduction to NoSQL Databases
Introduction to NoSQL DatabasesIntroduction to NoSQL Databases
Introduction to NoSQL DatabasesDerek Stainer
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenLorenzo Alberton
 
NoSQL Databases for Implementing Data Services – Should I Care?
NoSQL Databases for Implementing Data Services – Should I Care?NoSQL Databases for Implementing Data Services – Should I Care?
NoSQL Databases for Implementing Data Services – Should I Care?Guido Schmutz
 
Architektur von Big Data Lösungen
Architektur von Big Data LösungenArchitektur von Big Data Lösungen
Architektur von Big Data LösungenGuido Schmutz
 
Chaordic - BigData e MapReduce - Robson Motta
Chaordic - BigData e MapReduce - Robson Motta Chaordic - BigData e MapReduce - Robson Motta
Chaordic - BigData e MapReduce - Robson Motta Chaordic
 
Firebase Adventures - Going above and beyond in Realtime
Firebase Adventures - Going above and beyond in RealtimeFirebase Adventures - Going above and beyond in Realtime
Firebase Adventures - Going above and beyond in RealtimeJuarez Filho
 
Cassandra - Eine Einführung
Cassandra - Eine EinführungCassandra - Eine Einführung
Cassandra - Eine EinführungMikio L. Braun
 
Web Services and Mobile
Web Services and MobileWeb Services and Mobile
Web Services and MobileAvner Solomon
 
Principles of Service-Oriented Architecture
Principles of Service-Oriented ArchitecturePrinciples of Service-Oriented Architecture
Principles of Service-Oriented ArchitectureDouwe Pieter van den Bos
 
Leveraging SAP HANA with Apache Hadoop and SAP Analytics
Leveraging SAP HANA with Apache Hadoop and SAP AnalyticsLeveraging SAP HANA with Apache Hadoop and SAP Analytics
Leveraging SAP HANA with Apache Hadoop and SAP AnalyticsMethod360
 
Leveraging SAP, Hadoop, and Big Data to Redefine Business
Leveraging SAP, Hadoop, and Big Data to Redefine BusinessLeveraging SAP, Hadoop, and Big Data to Redefine Business
Leveraging SAP, Hadoop, and Big Data to Redefine BusinessDataWorks Summit
 
Lista de-precios-compugreiff-enero-14-2013
Lista de-precios-compugreiff-enero-14-2013Lista de-precios-compugreiff-enero-14-2013
Lista de-precios-compugreiff-enero-14-2013xxxxx
 
Industrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIROIndustrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIRODario Aguilar
 
Mercado Livre Experience - Matias Gualino
Mercado Livre Experience - Matias GualinoMercado Livre Experience - Matias Gualino
Mercado Livre Experience - Matias GualinoMatii Gualino
 
Personal branding project
Personal branding projectPersonal branding project
Personal branding projecttali92
 
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...creativecrowdsourcingleaks
 
Honduras Medical Mission
Honduras Medical MissionHonduras Medical Mission
Honduras Medical Missionwashingtonortho
 

Viewers also liked (20)

Introduction to NoSQL Databases
Introduction to NoSQL DatabasesIntroduction to NoSQL Databases
Introduction to NoSQL Databases
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and when
 
SQL vs. NoSQL
SQL vs. NoSQLSQL vs. NoSQL
SQL vs. NoSQL
 
NoSQL Databases for Implementing Data Services – Should I Care?
NoSQL Databases for Implementing Data Services – Should I Care?NoSQL Databases for Implementing Data Services – Should I Care?
NoSQL Databases for Implementing Data Services – Should I Care?
 
Architektur von Big Data Lösungen
Architektur von Big Data LösungenArchitektur von Big Data Lösungen
Architektur von Big Data Lösungen
 
Chaordic - BigData e MapReduce - Robson Motta
Chaordic - BigData e MapReduce - Robson Motta Chaordic - BigData e MapReduce - Robson Motta
Chaordic - BigData e MapReduce - Robson Motta
 
Firebase Adventures - Going above and beyond in Realtime
Firebase Adventures - Going above and beyond in RealtimeFirebase Adventures - Going above and beyond in Realtime
Firebase Adventures - Going above and beyond in Realtime
 
Drupal 6 Database layer
Drupal 6 Database layerDrupal 6 Database layer
Drupal 6 Database layer
 
Cassandra - Eine Einführung
Cassandra - Eine EinführungCassandra - Eine Einführung
Cassandra - Eine Einführung
 
Web Services and Mobile
Web Services and MobileWeb Services and Mobile
Web Services and Mobile
 
Principles of Service-Oriented Architecture
Principles of Service-Oriented ArchitecturePrinciples of Service-Oriented Architecture
Principles of Service-Oriented Architecture
 
Leveraging SAP HANA with Apache Hadoop and SAP Analytics
Leveraging SAP HANA with Apache Hadoop and SAP AnalyticsLeveraging SAP HANA with Apache Hadoop and SAP Analytics
Leveraging SAP HANA with Apache Hadoop and SAP Analytics
 
Leveraging SAP, Hadoop, and Big Data to Redefine Business
Leveraging SAP, Hadoop, and Big Data to Redefine BusinessLeveraging SAP, Hadoop, and Big Data to Redefine Business
Leveraging SAP, Hadoop, and Big Data to Redefine Business
 
Lista de-precios-compugreiff-enero-14-2013
Lista de-precios-compugreiff-enero-14-2013Lista de-precios-compugreiff-enero-14-2013
Lista de-precios-compugreiff-enero-14-2013
 
Industrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIROIndustrial Ecology KIGAM CSIRO
Industrial Ecology KIGAM CSIRO
 
Mercado Livre Experience - Matias Gualino
Mercado Livre Experience - Matias GualinoMercado Livre Experience - Matias Gualino
Mercado Livre Experience - Matias Gualino
 
Zaragoza Turismo 36
Zaragoza Turismo 36Zaragoza Turismo 36
Zaragoza Turismo 36
 
Personal branding project
Personal branding projectPersonal branding project
Personal branding project
 
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
Creative crowdsourcing - Specwork reflections and proposals - Travail spécula...
 
Honduras Medical Mission
Honduras Medical MissionHonduras Medical Mission
Honduras Medical Mission
 

Similar to Query Languages for Document Stores

Introduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQLIntroduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQLArangoDB Database
 
Whats new in_postgres_enterprise_db_20130124
Whats new in_postgres_enterprise_db_20130124Whats new in_postgres_enterprise_db_20130124
Whats new in_postgres_enterprise_db_20130124EDB
 
James Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 PatternsJames Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 Patternsakqaanoraks
 
Apache Airflow Architecture
Apache Airflow ArchitectureApache Airflow Architecture
Apache Airflow ArchitectureGerard Toonstra
 
CloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataCloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataTariq Iqbal
 
CloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataCloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataShapeBlue
 
James Jara Portfolio 2014 - Enterprise datagrid - Part 3
James Jara Portfolio 2014  - Enterprise datagrid - Part 3James Jara Portfolio 2014  - Enterprise datagrid - Part 3
James Jara Portfolio 2014 - Enterprise datagrid - Part 3James Jara
 
Cloud-based Energy Efficient Software
Cloud-based Energy Efficient SoftwareCloud-based Energy Efficient Software
Cloud-based Energy Efficient SoftwareFotis Stamatelopoulos
 
Hourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopHourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopMatthew Hayes
 
Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017
Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017
Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017Codemotion
 
Big Data Platform and Architecture Recommendation
Big Data Platform and Architecture RecommendationBig Data Platform and Architecture Recommendation
Big Data Platform and Architecture RecommendationSofyan Hadi AHmad
 
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal Srivatsan Ramanujam
 
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale ArangoDB Database
 
ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...
ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...
ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...Software AG
 
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013John Dalsgaard
 
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...Codemotion
 
Build Your Own Angular Component Library
Build Your Own Angular Component LibraryBuild Your Own Angular Component Library
Build Your Own Angular Component LibraryCarlo Bonamico
 
Working with CloudStack Usage Data - CCCEU13
Working with CloudStack Usage Data - CCCEU13Working with CloudStack Usage Data - CCCEU13
Working with CloudStack Usage Data - CCCEU13ShapeBlue
 
Working with CloudStack Usage Data
Working with CloudStack Usage DataWorking with CloudStack Usage Data
Working with CloudStack Usage DataTariq Iqbal
 

Similar to Query Languages for Document Stores (20)

Introduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQLIntroduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQL
 
Whats new in_postgres_enterprise_db_20130124
Whats new in_postgres_enterprise_db_20130124Whats new in_postgres_enterprise_db_20130124
Whats new in_postgres_enterprise_db_20130124
 
James Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 PatternsJames Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 Patterns
 
Apache Airflow Architecture
Apache Airflow ArchitectureApache Airflow Architecture
Apache Airflow Architecture
 
CloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataCloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage Data
 
CloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage DataCloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage Data
 
Triskell Autumn 2013 version (english)
Triskell Autumn 2013 version (english)Triskell Autumn 2013 version (english)
Triskell Autumn 2013 version (english)
 
James Jara Portfolio 2014 - Enterprise datagrid - Part 3
James Jara Portfolio 2014  - Enterprise datagrid - Part 3James Jara Portfolio 2014  - Enterprise datagrid - Part 3
James Jara Portfolio 2014 - Enterprise datagrid - Part 3
 
Cloud-based Energy Efficient Software
Cloud-based Energy Efficient SoftwareCloud-based Energy Efficient Software
Cloud-based Energy Efficient Software
 
Hourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on HadoopHourglass: a Library for Incremental Processing on Hadoop
Hourglass: a Library for Incremental Processing on Hadoop
 
Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017
Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017
Gabriele Nocco - Massive distributed processing with H2O - Codemotion Milan 2017
 
Big Data Platform and Architecture Recommendation
Big Data Platform and Architecture RecommendationBig Data Platform and Architecture Recommendation
Big Data Platform and Architecture Recommendation
 
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
Pivotal Data Labs - Technology and Tools in our Data Scientist's Arsenal
 
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale Webinar: ArangoDB 3.8 Preview - Analytics at Scale
Webinar: ArangoDB 3.8 Preview - Analytics at Scale
 
ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...
ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...
ARIS World: Shaping the Future of ARIS 9 - All You Need to Know About the Upc...
 
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
 
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...
Carlo Bonamico, Sonia Pini - So you want to build your (Angular) Component Li...
 
Build Your Own Angular Component Library
Build Your Own Angular Component LibraryBuild Your Own Angular Component Library
Build Your Own Angular Component Library
 
Working with CloudStack Usage Data - CCCEU13
Working with CloudStack Usage Data - CCCEU13Working with CloudStack Usage Data - CCCEU13
Working with CloudStack Usage Data - CCCEU13
 
Working with CloudStack Usage Data
Working with CloudStack Usage DataWorking with CloudStack Usage Data
Working with CloudStack Usage Data
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Query Languages for Document Stores

  • 1. © 2013 triAGENS GmbH | 2013-06-18 Query Languages for Document Stores 2013-06-18 Jan Steemann
  • 2. © 2013 triAGENS GmbH | 2013-06-18 me  I'm a software developer  working at triAGENS GmbH, CGN  on - a document store
  • 3. © 2013 triAGENS GmbH | 2013-06-18 Documents
  • 4. © 2013 triAGENS GmbH | 2013-06-18 Documents  documents are self-contained, aggregate data structures...  ...consisting of named and typed attributes, which can be nested / hierarchical  documents can be used to model complex business objects
  • 5. © 2013 triAGENS GmbH | 2013-06-18 Example order document {    "id": "abc­100­22",    "date": "2013­04­26"    "customer": {     "id": "c­199­023",     "name": "acme corp."   },   "items": [ {        "id": "p­123",       "quantity": 1,       "price": 25.13   } ] }  
  • 6. © 2013 triAGENS GmbH | 2013-06-18 Document stores  document stores are databases specialised in handling documents  they've been around for a while  got really popular with the NoSQL buzz (CouchDB, MongoDB, ...)
  • 7. © 2013 triAGENS GmbH | 2013-06-18 Why use Document Stores?
  • 8. © 2013 triAGENS GmbH | 2013-06-18 Saving programming language data  document stores allow saving a programming language object as a whole  your programming language object becomes a document in the database, without the need for much transformation  compare this to saving data in a relational database...
  • 9. © 2013 triAGENS GmbH | 2013-06-18 Persistence the relational way orders id date 1 2013-04-20 2 2013-04-21 3 2013-04-21 4 2013-04-22 customers customer c1 c2 c1 c3 id name c1 c2 c3 acme corp. sample.com abc co. orderitems 1 order item 1 price quantity 23.25 1
  • 10. © 2013 triAGENS GmbH | 2013-06-18 Benefits of document stores  no impedance mismatch, no complex object-relational mapping, no normalisation requirements  querying documents is often easier and faster than querying highly normalised relational data
  • 11. © 2013 triAGENS GmbH | 2013-06-18 Schema-less  in document stores, there is no "table"- schema as in the relational world  each document can have different attributes  there is no such thing as ALTER TABLE  that's why document stores are called schema-less or schema-free
  • 12. © 2013 triAGENS GmbH | 2013-06-18 Querying Document Stores
  • 13. © 2013 triAGENS GmbH | 2013-06-18 Querying by document id is easy  every document store allows querying a single document at a time  accessing documents by their unique ids is almost always dead-simple
  • 14. © 2013 triAGENS GmbH | 2013-06-18 Complex queries?  what if you want to run complex queries (e.g. projections, filters, aggregations, transformations, joins, ...)??  let's check the available options in some of the popular document stores
  • 15. © 2013 triAGENS GmbH | 2013-06-18 CouchDB: map-reduce  querying by something else than document key / id requires writing a view  views are JavaScript functions that are stored inside the database  views are populated by incremental map- reduce
  • 16. © 2013 triAGENS GmbH | 2013-06-18 map-reduce  the map function is applied on each document (that changed)  map can filter out non-matching documents  or emit modified or unmodified versions of them  emitted documents can optionally be passed into a reduce function  reduce is called with groups of similar documents and can thus perform aggregation
  • 17. © 2013 triAGENS GmbH | 2013-06-18 CouchDB map-reduce example map = function (doc) {   var i, n = doc.orderItems.length;   for (i = 0; i < n; ++i) {     emit(doc.orderItems[i], 1);   } }; reduce = function (keys, values, rereduce) {   if (rereduce) {     return sum(values);   }   return values.length; };
  • 18. © 2013 triAGENS GmbH | 2013-06-18 map-reduce  map-reduce is generic and powerful  provides a programming language  need to create views for everything that is queried  access to a single "table" at a time (no cross-"table" views)  a bit clumsy for ad-hoc exploratory queries
  • 19. © 2013 triAGENS GmbH | 2013-06-18 MongoDB: find()  ad-hoc queries in MongoDB are much easier  can directly apply filters on collections, allowing to find specific documents easily: mongo> db.orders.find({    "customer": {      "id": "c1",     "name": "acme corp."   } });
  • 20. © 2013 triAGENS GmbH | 2013-06-18 MongoDB: complex filters  can filter on any document attribute or sub-attribute  indexes will automatically be used if present  nesting filters allows complex queries  quite flexible and powerful, but tends to be hard to use and read for more complex queries
  • 21. © 2013 triAGENS GmbH | 2013-06-18 MongoDB: complex filtering mongo> db.users.find({    "$or": [      {        "active": true      },      {        "age": {          "$gte": 40        }      }    ] });
  • 22. © 2013 triAGENS GmbH | 2013-06-18 MongoDB: more options  can also use JavaScript functions for filtering, or JavaScript map-reduce  several aggregation functions are also provided  neither option allows running cross-"table" queries
  • 23. © 2013 triAGENS GmbH | 2013-06-18 Why not use a Query Language?
  • 24. © 2013 triAGENS GmbH | 2013-06-18 Query languages  a good query language should  allow writing both simple and complex queries, without having to switch the methodology  provide the required features for filtering, aggregation, joining etc.  hide the database internals
  • 25. © 2013 triAGENS GmbH | 2013-06-18 SQL  in the relational world, there is one accepted general-purpose query language: SQL  it is quite well-known and mature:  35+ years of experience  many developers and established tools around it  standardised (but mind the "dialects"!)
  • 26. © 2013 triAGENS GmbH | 2013-06-18 SQL in document stores?  SQL is good at handling relational data  not good at handling multi-valued or hierchical attributes, which are common in documents  (too) powerful: SQL provides features many document stores intentionally lack (e.g. joins, transactions)  SQL has not been adopted by document stores yet
  • 27. © 2013 triAGENS GmbH | 2013-06-18 Query Languages for Document Stores
  • 28. © 2013 triAGENS GmbH | 2013-06-18 XQuery?  XQuery is a query and programming language  targeted mainly at processing XML data  can process hierarchical data  very powerful and extensible  W3C recommendation
  • 29. © 2013 triAGENS GmbH | 2013-06-18 XQuery  XQuery has found most adoption in the area of XML processing  today people want to use JSON, not XML  XQuery not available in popular document stores
  • 30. © 2013 triAGENS GmbH | 2013-06-18 ArangoDB Query Language (AQL)  ArangoDB provides AQL, a query language made for JSON document processing  it allows running complex queries on documents, including joins and aggregation  language syntax was inspired by XQuery and provides similar concepts such as FOR, LET, RETURN, ...  the language integrates JSON "naturally"
  • 31. © 2013 triAGENS GmbH | 2013-06-18 AQL example FOR order IN orders   FILTER order.status == "processed"   LET itemsValue = SUM((     FOR item IN order.items       FILTER item.status == "confirmed"       RETURN item.price * item.quantity   ))   FILTER itemsValue >= 500   RETURN {     "items"      : order.items,     "itemsValue" : itemsValue,     "itemsCount" : LENGTH(order.items)   }
  • 32. © 2013 triAGENS GmbH | 2013-06-18 AQL: some features  queries can combine data from multiple "tables"  this allows joins using any document attributes or sub-attributes  indexes will be used if present
  • 33. © 2013 triAGENS GmbH | 2013-06-18 AQL: join example FOR user IN users   FILTER user.id == 1234   RETURN {     "user"  : user,     "posts" : (FOR post IN blogPosts       FILTER post.userId == user.id &&              post.date >= '2013­06­13'                    RETURN post     )   }
  • 34. © 2013 triAGENS GmbH | 2013-06-18 AQL: additional features  AQL provides basic functionality to query graphs, too  the language can be extended with user- defined JavaScript functions
  • 35. © 2013 triAGENS GmbH | 2013-06-18 JSONiq  JSONiq is a data processing and query language for handling JSON data  it is based on XQuery, thus provides the same FLWOR expressions: FOR, LET, WHERE, ORDER, ...  JSON is integrated "naturally"  most of the XML handling is removed
  • 36. © 2013 triAGENS GmbH | 2013-06-18 JSONiq: example for $order in collection("orders")   where $order.customer.id eq "abc­123"   return {     customer : $order.customer,     items    : $order.items   }
  • 37. © 2013 triAGENS GmbH | 2013-06-18 JSONiq: join example for $post in collection("posts")   let $postId := $post.id   for $comment in collection("comments")     where $comment.postId eq $postId     group by $postId     order by count($comment) descending     return {       id       : $postId,       comments : count($comment)     }
  • 38. © 2013 triAGENS GmbH | 2013-06-18 JSONiq  JSONiq is a generic, database-agnostic language  it can be extended with user-defined XQuery functions  JSONiq is currently not implemented inside any document database...
  • 39. © 2013 triAGENS GmbH | 2013-06-18 JSONiq  ...but it can be used via a service (at 28.io)  the service provides the JSONiq query language and implements functionality not provided by a specific database  such features are implemented client-side, e.g. joins for MongoDB
  • 40. © 2013 triAGENS GmbH | 2013-06-18 Summary
  • 41. © 2013 triAGENS GmbH | 2013-06-18 Summary  today's document stores provide different, proprietary mechanisms for querying data  there is currently no standard query mechanism for document stores as there is in the relational world (SQL)
  • 42. © 2013 triAGENS GmbH | 2013-06-18 Summary  you CAN use query languages in document stores today, e.g. AQL and JSONiq  if you like the idea, give them a try, provide feedback and contribute!