“n1ql” a rich query language for couchbase: presented by don pinto, couchbase

20

Upload: lucidworks

Post on 15-Jul-2015

352 views

Category:

Software


2 download

TRANSCRIPT

Page 1: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase
Page 2: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

“N1QL” A Rich Query Language For Couchbase Don Pinto Sr. Product Manager, Couchbase

Page 3: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

Agenda •  Rich data •  Compare relational and N1QL data model •  Mission •  Resources •  Q&A •  Demo

Page 4: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

The Real World

Page 5: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

Couchbase Server

General  purpose  

Elas-c  scalability     Consistent  high  performance  

Always  available   Flexible,  global  deployment  

Enterprise  grade  administra-on  

Real  -me  big  data  

Data  mobility  

Developer  focused  

The  Most  complete,  scalable  &  highest  performing  NoSQL  database  

Page 6: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

Couchbase Server

Couchbase  offers  a  full  range  of  Data  Management  solu5ons  

High  Availability  Cache  

Key  Value   Document   Mobile  device  

SSN:  400  658  9993  Pass:  ******  

Page 7: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

A Basic Data Model §  Tables, schemas, constraints

§  Prevailing model for 30+ years

Page 8: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

A Rich Data Model

8  

Person  

Name    

DOB      

Billing      

Connec5ons            

Purchases  

Jane  Smith  

Product  

Jan-­‐30-­‐1990  

Human         Machine  

§  Structure and richness of real-world data

§  Drivers: Big Data, agility

§  Enabler: JSON — convenient, standard

Page 9: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

9  

Basic  Data  Model   Rich  Data  Model  

Technology   q Rela-onal   v Document  

Building  blocks  

§  Flat  tables   ü  Rich  objects  

Developer  impact  

§  Real  world  must  be  translated  

§  Objects  must  be  assembled  

§  Data  must  be  uniform  

§  Change  must  be  an  excep-on  

ü  Real  world  can  be  reflected  

ü  Objects  can  be  represented  

ü  Data  can  be  uniform  or  varied  

ü  Change  can  be  a  norm  

Query  language   q  SQL   v  N1QL  —  SQL  and  more  

Comparing the data models

Page 10: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

10  

JSON:  Rich  Data  SQL:  Expressive  Power   N1NF  

N1QL    

N1QL:  Query  Language  for  Rich  Data  

Defining N1QL

Page 11: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

11  

Ø  Power  for  Big  Data  Applica5ons  §  Ability  to  index  and  query  rich  data  at  scale  §  Power  of  Couchbase  extended  to  querying  

Ø  Joy  for  Developers  §  Freedom,  flexibility,  alignment,  produc-vity  §   Best  of  both  —  SQL  and  rich  data  

Ø  Value  for  Customers  §  Query  technology  for  a  new  era  §  Enabler  for  applica-ons  of  the  future  

What does N1QL achieve?

Page 12: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

12  

Reading  Data  

SELECT   Projec-on  

DISTINCT   De-­‐duplica-on  

FROM   Sourcing  

JOIN   INNER,  LEFT  OUTER  

WHERE   Filtering  

GROUP  BY   Aggrega-on  —  HAVING,  MIN,  MAX,  SUM,  AVG,  COUNT  [  DISTINCT  ]  

ORDER  BY   Sor-ng  

LIMIT,  OFFSET   Paging  

UNION*,  INTERSECT*,  EXCEPT*   Set  operators  

EXPLAIN   Analyzing  and  tuning  query  execu-on  plans  

N1QL Features - Reads *Upcoming

Page 13: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

13  

Wri5ng  Data  

CREATE  INDEX   Create  a  Couchbase  view  index  or  secondary  index*  

DROP  INDEX   Drop  an  index  

INSERT*   INSERT  using  VALUES  or  SELECT  

UPDATE*   UPDATE…WHERE,  with  document-­‐level  atomicity  

DELETE*   DELETE  FROM…WHERE,  with  document-­‐level  atomicity  

MERGE*   MERGE  with  INSERT  or  UPDATE,  depending  on  match  

N1QL Features - Writes

*Upcoming

Page 14: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

14  

Expressions  

Literals  Primi-ves  [  0,  ‘hello’,  TRUE  ]  

NULL  

Operators  

Arithme-c  [  +,  -­‐,  *,  /,  %  ]  

Logical  [  AND,  OR,  NOT  ]  

Comparison  [  <,  <=,  =,  !=,  >=,  >,  BETWEEN,  IS  NULL  ]  

Papern  matching  [  LIKE  ]  

Condi-onal  [  CASE  ]  

Scalar  func-ons  

Numeric  [  trigonometric,  ROUND,  TRUNC,  …  ]  

String  [  UPPER,  LOWER,  TRIM,  SUBSTR,  …  ]  

Date  [  string  and  numeric  dates,  NOW,  date  arithme-c*,  …  ]  

Aggregate  func-ons   MIN,  MAX,  SUM,  AVG,  COUNT  [  DISTINCT  ]  

Subqueries*   Subqueries  are  full  expressions  

N1QL Features - Expressions *Upcoming

Page 15: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

15  

Nested  Data  

Mul--­‐valued  apributes   Arrays  as  apributes  

Nested  objects   Mul--­‐level  nes-ng  of  objects;  path  naviga-on  

NEST   Collec-ng  second  term  into  nested  array  [  INNER,  LEFT  OUTER  ]  

UNNEST   Flapening  nested  array  [  INNER,  LEFT  OUTER  ]  

Collec-on  operators   Mapping,  filtering,  predicate,  indexing,  and  slicing  operators  

Collec-on  func-ons   Sort,  Reverse,  Dis-nct,  Append,  Concatenate,  Contains…  

Collec-on  aggrega-on*   MIN,  MAX,  SUM,  AVG,  COUNT  [  DISTINCT  ]  

Deep  traversal*   Finding  or  collec-ng  of  matching  elements  WITHIN  any  depth  

Array  and  deep  update*   UPDATE  of  matching  elements  IN  arrays  and  WITHIN  any  depth  

Construc-on   Dynamic  construc-on  of  objects,  arrays,  and  their  combina-ons  

*Upcoming

Rich Data Features - Nesting

Page 16: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

Heterogeneous  Data  

Heterogeneous  inputs   Input  data  of  varying  structure  and  type  

Heterogeneous  results   Results  of  varying  structure  and  type  

Raw  projec-on   Support  for  non-­‐tuple,  non-­‐object  results  

Schema  inference*   Inference  of  result  structure  and  types,  based  on  result  expressions  

Missing  apributes   IS  [  NOT  ]  MISSING  and  other  operators  and  func-ons  

Apribute  removal*   UPDATE…UNSET  to  remove  apributes  

Total  ordering*   Comparison  and  ordering  for  all  values,  across  all  types  

Implicit  types*  §  Type-­‐encoding  func-ons  +  expression  indexes*  

§  For  example,  range  scans  on  dates  

Closure   JSON  in,  JSON  out  

Features for Rich Data — Heterogeneity

16  

*Upcoming

Page 17: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

17  

Distributed  Data  

Key-­‐value  access  §  KEYS  available  in  SELECT,  UPDATE,  DELETE  

§  KEYS  used  in  JOIN,  NEST,  subqueries*,  MERGE*  

Document  metadata   § META  func-on  to  access  ID,  TTL,  CAS,  FLAGS…  

LIMIT  on  UPDATE  &  DELETE*   §  LIMIT  available  in  write  statements  

Features for Distributed Data

*Upcoming

Page 18: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

18  

j

Ø  query.couchbase.com  §  Downloads  §  Tutorial  §  Documenta-on  §  Blogs  §  Webinars  §  Forum  

Ø @N1QL  §  Follow  us  §  Engage  

Resources

Page 19: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase
Page 20: “N1QL” a Rich Query Language for Couchbase: Presented by Don Pinto, Couchbase

Thank you!

@NoSQLDon | [email protected]