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.

04508bb89d3b21194b8db953d218b992?s=128

William Candillon

April 16, 2013
Tweet

Transcript

  1. JSONiq The SQL of NoSQL William Candillon - w@28.io

  2. Scalable Document Store + Productive  Query  Language = Database

  3. Standardization Complex Processing Functions & Operators

  4. Standarization

  5. 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 “ ”
  6. 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
  7. Standarization

  8. 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 } ...
  9. 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 } ...
  10. Complex Processing

  11. 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 } ...
  12. 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 } ...
  13. Functions & Operators

  14. "Luke, I am your father" contains text "dad" false

  15. "Luke, I am your father" contains text "dad" using thesaurus

    default true
  16. 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 ...
  17. let $date := current-date() let $mask := "[D]. [MNn] [Y]"

    let $code := "de_DE" return format-date($date, $mask, $code) 1. Januar 2013
  18. sim:soundex-key("Robert") eq sim:soundex-key("Rupert") true

  19. None
  20. Put the pressure back to the query language

  21. None
  22. Demo http://28.io/demo

  23. Thank You !