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
 
Build Your Own Angular Component Library
Build Your Own Angular Component LibraryBuild Your Own Angular Component Library
Build Your Own Angular Component LibraryCarlo Bonamico
 
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
 
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
 
Build Your Own Angular Component Library
Build Your Own Angular Component LibraryBuild Your Own Angular Component Library
Build Your Own Angular Component Library
 
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...
 
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

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

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!