Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JSONiq - The SQL of NoSQL

JSONiq - The SQL of NoSQL

JSONiq supports complex SQL-like queries such as (outer-)joins, grouping, sorting, transformation, full-text, indexes, and declarative updates. It brings powerful queries database users take for granted in SQL to NoSQL without giving up on scalability.

William Candillon

April 16, 2013
Tweet

More Decks by William Candillon

Other Decks in Programming

Transcript

  1. The RDBMS is sailing into the sunset. But if NoSQL

    is to take its place, a standard query language must emerge soon Andrew Oliver - InfoWorld “ ”
  2. Open Specification: jsoniq.org Contributors: 28msec, Oracle, and EMC Implementations: Zorba

    (zorba.io), Xidel Connectors: MongoDB, Couchbase, JDBC, and more Formal Semantic: XQuery 3.0 from W3C JSONiq
  3. for $zip in couchbase:view($db, "zips").rows group by $state := $zip.key

    let $pop := sum($zip.value) order by $state descending return { "state" : $state, "population" : $pop } { "state": "CA", "population": 33871 } { "state": "TX", "population": 26059 } { "state": "NY", "population": 19570 } ...
  4. for $zip in mongo:find($db,"zips") group by $state := $zip.key let

    $pop := sum($zip.value) order by $state descending return { "state" : $state, "population" : $pop } { "state": "CA", "population": 33871 } { "state": "TX", "population": 26059 } { "state": "NY", "population": 19570 } ...
  5. for $answers in db:collection("answers") group by $id := $answers.question_id let

    $count := count($answers) order by $count descending return { "user" : db:collection("faq") [$$.question_id eq $id].title, "count" : $count } { "user": "jbellis", "count": 6 } { "user": "user1557698", "count": 5 } { "user": "nawroth", "count": 5 } ...
  6. max( for tumbling window $answers in db:collection("answers") start $start when

    true only end $end next $next when $next.date - $end.date gt dayTimeDuration("P1D") return $end.date - $start.date ) { "user": "jbellis", "streak": 2 } { "user": "user1557698", "streak": 1 } { "user": "nawroth", "streak": 1 } ...
  7. let $s := "These are not the droids you are

    looking for" let $tokens := ft:tokenize-string($s) for $token in $tokens where not(ft:is-stop-word($token)) return ft:stem($token) droid look ...
  8. let $date := current-date() let $mask := "[D]. [MNn] [Y]"

    let $code := "de_DE" return format-date($date, $mask, $code) 1. Januar 2013