SlideShare a Scribd company logo

PGQL: A Language for Graphs

J
Jean Ihm

5th in the AskTOM Office Hours series on graph database technologies. https://devgym.oracle.com/pls/apex/dg/office_hours/3084 PGQL: A Query Language for Graphs Learn how to query graphs using PGQL, an expressive and intuitive graph query language that's a lot like SQL. With PGQL, it's easy to get going writing graph analysis queries to the database in a very short time. Albert and Oskar show what you can do with PGQL, and how to write and execute PGQL code.

1 of 48
Download to read offline
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Oracle Ask TOM Office Hours:
A Language for Graphs: PGQL
Albert Godfrind, Solutions Architect @agodfrin
Oskar Van Rest @oskarvanrest
Jean Ihm, Product Manager @JeanIhm
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
AskTOM sessions on property graphs
• Today’s is the fifth session on property graphs
– February’s session introduced Property Graphs
– March's session explained how to model graphs from relational data
– May's session explained how to perform graph analytics
– August's session showed how we could view graphs
– In case you missed them, recordings are available at the URL above
• Today’s topic: PGQL: A language for Graphs
• Visit the Spatial and Graph landing page to view recordings; submit
feedback, questions, topic requests; view upcoming session dates and
topics; sign up
2
https://devgym.oracle.com/pls/apex/dg/office_hours/3084
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
3
The Story So Far …
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Oracle Big Data Spatial and Graph
• Available for Big Data platform/BDCS
– Hadoop, HBase, Oracle NoSQL
• Supported both on BDA and commodity
hardware
– CDH and Hortonworks
• Database connectivity through Big Data
Connectors or Big Data SQL
• Included in Big Data Cloud Service
Oracle Spatial and Graph
• Available with Oracle 18c/12.2/DBCS
• Using tables for graph persistence
• Graph views on relational data
• In-database graph analytics
– Sparsification, shortest path, page rank, triangle
counting, WCC, sub graphs
• SQL queries possible
• Included in Database Cloud Service
4
Graph Product Options
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Graph Storage Management
5
Architecture of Property Graph
Graph Analytics
Blueprints/Tinkerpop/Gremlin
REST/WebService
APIs
Java,Groovy,Python,…
Scalable and Persistent Storage
Oracle NoSQL
Database
Oracle RDBMS Apache HBase
What we focus
on now
Parallel In-Memory Graph Analytics
pgql> SELECT ...
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
• What is a graph?
– Data model representing entities as
vertices and relationships as edges
– Optionally including attributes
• Flexible data model
– No predefined schema, easily extensible
– Particularly useful for sparse data
• Enabling new kinds of analytics
– Overcoming limitations in relational
technology
6
Graph Data Model
E
A D
C B
F
Ad

Recommended

[Pgday.Seoul 2020] SQL Tuning
[Pgday.Seoul 2020] SQL Tuning[Pgday.Seoul 2020] SQL Tuning
[Pgday.Seoul 2020] SQL TuningPgDay.Seoul
 
[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자
[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자
[Pgday.Seoul 2017] 7. PostgreSQL DB Tuning 기업사례 - 송춘자PgDay.Seoul
 
Kakao Cloud Native Platform, 9rum
Kakao Cloud Native Platform, 9rumKakao Cloud Native Platform, 9rum
Kakao Cloud Native Platform, 9rumif kakao
 
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo..."Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...
"Spark Search" - In-memory, Distributed Search with Lucene, Spark, and Tachyo...Lucidworks
 
事例から見る規模別クラウド・データベースの選び方 (Oracle Database) (Oracle Cloudウェビナーシリーズ: 2021年6月30日)
事例から見る規模別クラウド・データベースの選び方 (Oracle Database) (Oracle Cloudウェビナーシリーズ: 2021年6月30日)事例から見る規模別クラウド・データベースの選び方 (Oracle Database) (Oracle Cloudウェビナーシリーズ: 2021年6月30日)
事例から見る規模別クラウド・データベースの選び方 (Oracle Database) (Oracle Cloudウェビナーシリーズ: 2021年6月30日)オラクルエンジニア通信
 
Learning to Rank in Solr: Presented by Michael Nilsson & Diego Ceccarelli, Bl...
Learning to Rank in Solr: Presented by Michael Nilsson & Diego Ceccarelli, Bl...Learning to Rank in Solr: Presented by Michael Nilsson & Diego Ceccarelli, Bl...
Learning to Rank in Solr: Presented by Michael Nilsson & Diego Ceccarelli, Bl...Lucidworks
 

More Related Content

What's hot

[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQLPgDay.Seoul
 
Salesforce1 PlatformアーキテクチャWebinar
Salesforce1 PlatformアーキテクチャWebinarSalesforce1 PlatformアーキテクチャWebinar
Salesforce1 PlatformアーキテクチャWebinarSalesforce Developers Japan
 
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)オラクルエンジニア通信
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuingGurpreet singh
 
Oracle Cloud Infrastructure:2022年8月度サービス・アップデート
Oracle Cloud Infrastructure:2022年8月度サービス・アップデートOracle Cloud Infrastructure:2022年8月度サービス・アップデート
Oracle Cloud Infrastructure:2022年8月度サービス・アップデートオラクルエンジニア通信
 
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...Amazon Web Services Korea
 
[215] Druid로 쉽고 빠르게 데이터 분석하기
[215] Druid로 쉽고 빠르게 데이터 분석하기[215] Druid로 쉽고 빠르게 데이터 분석하기
[215] Druid로 쉽고 빠르게 데이터 분석하기NAVER D2
 
한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...
한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...
한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...Amazon Web Services Korea
 
The Graph Traversal Programming Pattern
The Graph Traversal Programming PatternThe Graph Traversal Programming Pattern
The Graph Traversal Programming PatternMarko Rodriguez
 
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018 금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018 Amazon Web Services Korea
 
Oci object storage deep dive 20190329 ss
Oci object storage deep dive 20190329 ssOci object storage deep dive 20190329 ss
Oci object storage deep dive 20190329 ssKenichi Sonoda
 
MySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR ScenariosMySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR ScenariosKeith Hollman
 
Information Design Tool -Tutorial4
Information Design Tool -Tutorial4Information Design Tool -Tutorial4
Information Design Tool -Tutorial4Obily W
 
とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...
とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...
とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...オラクルエンジニア通信
 
グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介
グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介
グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介ippei_suzuki
 
How to Take Advantage of Optimizer Improvements in MySQL 8.0
How to Take Advantage of Optimizer Improvements in MySQL 8.0How to Take Advantage of Optimizer Improvements in MySQL 8.0
How to Take Advantage of Optimizer Improvements in MySQL 8.0Norvald Ryeng
 
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021Amazon Web Services Korea
 

What's hot (20)

[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
[Pgday.Seoul 2021] 1. 예제로 살펴보는 포스트그레스큐엘의 독특한 SQL
 
Salesforce1 PlatformアーキテクチャWebinar
Salesforce1 PlatformアーキテクチャWebinarSalesforce1 PlatformアーキテクチャWebinar
Salesforce1 PlatformアーキテクチャWebinar
 
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)
Oracle Database: リリースモデルとアップグレード・パッチ計画 (2021年2月版)
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuing
 
Oracle Cloud Infrastructure:2022年8月度サービス・アップデート
Oracle Cloud Infrastructure:2022年8月度サービス・アップデートOracle Cloud Infrastructure:2022年8月度サービス・アップデート
Oracle Cloud Infrastructure:2022年8月度サービス・アップデート
 
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
 
Cloudformation101
Cloudformation101Cloudformation101
Cloudformation101
 
[215] Druid로 쉽고 빠르게 데이터 분석하기
[215] Druid로 쉽고 빠르게 데이터 분석하기[215] Druid로 쉽고 빠르게 데이터 분석하기
[215] Druid로 쉽고 빠르게 데이터 분석하기
 
한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...
한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...
한글과컴퓨터의 클라우드 마이그레이션, 거버넌스 그리고 모더나이제이션-박인재, AWS ISV SA Manager / 박상형, 한글과컴퓨터 I...
 
Les 16 resource
Les 16 resourceLes 16 resource
Les 16 resource
 
The Graph Traversal Programming Pattern
The Graph Traversal Programming PatternThe Graph Traversal Programming Pattern
The Graph Traversal Programming Pattern
 
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018 금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018
금융사의 AWS기반 Digital Transformation 사례::고종원::AWS Summit Seoul 2018
 
Oci object storage deep dive 20190329 ss
Oci object storage deep dive 20190329 ssOci object storage deep dive 20190329 ss
Oci object storage deep dive 20190329 ss
 
MySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR ScenariosMySQL Enterprise Backup - BnR Scenarios
MySQL Enterprise Backup - BnR Scenarios
 
Information Design Tool -Tutorial4
Information Design Tool -Tutorial4Information Design Tool -Tutorial4
Information Design Tool -Tutorial4
 
とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...
とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...
とっておきの方法! Oracle Databaseの自動アップグレードのお勧め手法 省力・最新化 概要編 (Oracle Cloudウェビナーシリーズ: ...
 
グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介
グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介
グラフデータベース:Neo4j、そしてRDBからの移行手順の紹介
 
How to Take Advantage of Optimizer Improvements in MySQL 8.0
How to Take Advantage of Optimizer Improvements in MySQL 8.0How to Take Advantage of Optimizer Improvements in MySQL 8.0
How to Take Advantage of Optimizer Improvements in MySQL 8.0
 
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
 
PostgreSQL
PostgreSQL PostgreSQL
PostgreSQL
 

Similar to PGQL: A Language for Graphs

Introduction to Property Graph Features (AskTOM Office Hours part 1)
Introduction to Property Graph Features (AskTOM Office Hours part 1) Introduction to Property Graph Features (AskTOM Office Hours part 1)
Introduction to Property Graph Features (AskTOM Office Hours part 1) Jean Ihm
 
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...Databricks
 
Python and the MySQL Document Store
Python and the MySQL Document StorePython and the MySQL Document Store
Python and the MySQL Document StoreJesper Wisborg Krogh
 
Microsoft R Server for Data Sciencea
Microsoft R Server for Data ScienceaMicrosoft R Server for Data Sciencea
Microsoft R Server for Data ScienceaData Science Thailand
 
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...Jean Ihm
 
Multiplatform Spark solution for Graph datasources by Javier Dominguez
Multiplatform Spark solution for Graph datasources by Javier DominguezMultiplatform Spark solution for Graph datasources by Javier Dominguez
Multiplatform Spark solution for Graph datasources by Javier DominguezBig Data Spain
 
Follow the money with graphs
Follow the money with graphsFollow the money with graphs
Follow the money with graphsStanka Dalekova
 
20190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev220190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev2Ivan Ma
 
NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...
NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...
NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...Amazon Web Services
 
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝OSS On Azure
 
Gain Insights with Graph Analytics
Gain Insights with Graph Analytics Gain Insights with Graph Analytics
Gain Insights with Graph Analytics Jean Ihm
 
MySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMorgan Tocker
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Amazon Web Services
 
A Hands-on Intro to Data Science and R Presentation.ppt
A Hands-on Intro to Data Science and R Presentation.pptA Hands-on Intro to Data Science and R Presentation.ppt
A Hands-on Intro to Data Science and R Presentation.pptSanket Shikhar
 
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Amazon Web Services
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Codemotion
 
Applying large scale text analytics with graph databases
Applying large scale text analytics with graph databasesApplying large scale text analytics with graph databases
Applying large scale text analytics with graph databasesData Ninja API
 
SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP Dave Stokes
 
TensorFlow 16: Building a Data Science Platform
TensorFlow 16: Building a Data Science Platform TensorFlow 16: Building a Data Science Platform
TensorFlow 16: Building a Data Science Platform Seldon
 
Develop Python Applications with MySQL Connector/Python
Develop Python Applications with MySQL Connector/PythonDevelop Python Applications with MySQL Connector/Python
Develop Python Applications with MySQL Connector/PythonJesper Wisborg Krogh
 

Similar to PGQL: A Language for Graphs (20)

Introduction to Property Graph Features (AskTOM Office Hours part 1)
Introduction to Property Graph Features (AskTOM Office Hours part 1) Introduction to Property Graph Features (AskTOM Office Hours part 1)
Introduction to Property Graph Features (AskTOM Office Hours part 1)
 
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
 
Python and the MySQL Document Store
Python and the MySQL Document StorePython and the MySQL Document Store
Python and the MySQL Document Store
 
Microsoft R Server for Data Sciencea
Microsoft R Server for Data ScienceaMicrosoft R Server for Data Sciencea
Microsoft R Server for Data Sciencea
 
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...
 
Multiplatform Spark solution for Graph datasources by Javier Dominguez
Multiplatform Spark solution for Graph datasources by Javier DominguezMultiplatform Spark solution for Graph datasources by Javier Dominguez
Multiplatform Spark solution for Graph datasources by Javier Dominguez
 
Follow the money with graphs
Follow the money with graphsFollow the money with graphs
Follow the money with graphs
 
20190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev220190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev2
 
NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...
NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...
NEW LAUNCH! How to build graph applications with SPARQL and Gremlin using Ama...
 
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝
 
Gain Insights with Graph Analytics
Gain Insights with Graph Analytics Gain Insights with Graph Analytics
Gain Insights with Graph Analytics
 
MySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer Guide
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
 
A Hands-on Intro to Data Science and R Presentation.ppt
A Hands-on Intro to Data Science and R Presentation.pptA Hands-on Intro to Data Science and R Presentation.ppt
A Hands-on Intro to Data Science and R Presentation.ppt
 
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
 
Applying large scale text analytics with graph databases
Applying large scale text analytics with graph databasesApplying large scale text analytics with graph databases
Applying large scale text analytics with graph databases
 
SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP
 
TensorFlow 16: Building a Data Science Platform
TensorFlow 16: Building a Data Science Platform TensorFlow 16: Building a Data Science Platform
TensorFlow 16: Building a Data Science Platform
 
Develop Python Applications with MySQL Connector/Python
Develop Python Applications with MySQL Connector/PythonDevelop Python Applications with MySQL Connector/Python
Develop Python Applications with MySQL Connector/Python
 

More from Jean Ihm

Oracle Spatial Studio: Fast and Easy Spatial Analytics and Maps
Oracle Spatial Studio:  Fast and Easy Spatial Analytics and MapsOracle Spatial Studio:  Fast and Easy Spatial Analytics and Maps
Oracle Spatial Studio: Fast and Easy Spatial Analytics and MapsJean Ihm
 
Build Knowledge Graphs with Oracle RDF to Extract More Value from Your Data
Build Knowledge Graphs with Oracle RDF to Extract More Value from Your DataBuild Knowledge Graphs with Oracle RDF to Extract More Value from Your Data
Build Knowledge Graphs with Oracle RDF to Extract More Value from Your DataJean Ihm
 
Icde2019 improving rdf query performance using in-memory virtual columns in o...
Icde2019 improving rdf query performance using in-memory virtual columns in o...Icde2019 improving rdf query performance using in-memory virtual columns in o...
Icde2019 improving rdf query performance using in-memory virtual columns in o...Jean Ihm
 
Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...
Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...
Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...Jean Ihm
 
When Graphs Meet Machine Learning
When Graphs Meet Machine LearningWhen Graphs Meet Machine Learning
When Graphs Meet Machine LearningJean Ihm
 
How To Visualize Graphs
How To Visualize GraphsHow To Visualize Graphs
How To Visualize GraphsJean Ihm
 
An Introduction to Graph: Database, Analytics, and Cloud Services
An Introduction to Graph:  Database, Analytics, and Cloud ServicesAn Introduction to Graph:  Database, Analytics, and Cloud Services
An Introduction to Graph: Database, Analytics, and Cloud ServicesJean Ihm
 

More from Jean Ihm (7)

Oracle Spatial Studio: Fast and Easy Spatial Analytics and Maps
Oracle Spatial Studio:  Fast and Easy Spatial Analytics and MapsOracle Spatial Studio:  Fast and Easy Spatial Analytics and Maps
Oracle Spatial Studio: Fast and Easy Spatial Analytics and Maps
 
Build Knowledge Graphs with Oracle RDF to Extract More Value from Your Data
Build Knowledge Graphs with Oracle RDF to Extract More Value from Your DataBuild Knowledge Graphs with Oracle RDF to Extract More Value from Your Data
Build Knowledge Graphs with Oracle RDF to Extract More Value from Your Data
 
Icde2019 improving rdf query performance using in-memory virtual columns in o...
Icde2019 improving rdf query performance using in-memory virtual columns in o...Icde2019 improving rdf query performance using in-memory virtual columns in o...
Icde2019 improving rdf query performance using in-memory virtual columns in o...
 
Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...
Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...
Powerful Spatial Features You Never Knew Existed in Oracle Spatial and Graph ...
 
When Graphs Meet Machine Learning
When Graphs Meet Machine LearningWhen Graphs Meet Machine Learning
When Graphs Meet Machine Learning
 
How To Visualize Graphs
How To Visualize GraphsHow To Visualize Graphs
How To Visualize Graphs
 
An Introduction to Graph: Database, Analytics, and Cloud Services
An Introduction to Graph:  Database, Analytics, and Cloud ServicesAn Introduction to Graph:  Database, Analytics, and Cloud Services
An Introduction to Graph: Database, Analytics, and Cloud Services
 

Recently uploaded

Operations Data On Mobile - inSis Mobile App - Sample Screens
Operations Data On Mobile - inSis Mobile App - Sample ScreensOperations Data On Mobile - inSis Mobile App - Sample Screens
Operations Data On Mobile - inSis Mobile App - Sample ScreensKondapi V Siva Rama Brahmam
 
Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...
Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...
Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...Thibaud Le Douarin
 
A Gentle Introduction to Text Analysis :)
A Gentle Introduction to Text Analysis :)A Gentle Introduction to Text Analysis :)
A Gentle Introduction to Text Analysis :)UNCResearchHub
 
itc limited word file.pdf...............
itc limited word file.pdf...............itc limited word file.pdf...............
itc limited word file.pdf...............mahetamanav24
 
IIBA Adl - Being Effective on Day 1 - Slide Deck.pdf
IIBA Adl - Being Effective on Day 1 - Slide Deck.pdfIIBA Adl - Being Effective on Day 1 - Slide Deck.pdf
IIBA Adl - Being Effective on Day 1 - Slide Deck.pdfAustraliaChapterIIBA
 
Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...ThinkInnovation
 
Business Analytics _ Confidence Interval
Business Analytics _ Confidence IntervalBusiness Analytics _ Confidence Interval
Business Analytics _ Confidence IntervalRavindra Nath Shukla
 
Tips to Align with Your Salesforce Data Goals
Tips to Align with Your Salesforce Data GoalsTips to Align with Your Salesforce Data Goals
Tips to Align with Your Salesforce Data GoalsDataArchiva
 
AWS Identity and access management for users
AWS Identity and access management for usersAWS Identity and access management for users
AWS Identity and access management for usersStephenEfange3
 
fundamentals of digital imaging - POONAM.pptx
fundamentals of digital imaging - POONAM.pptxfundamentals of digital imaging - POONAM.pptx
fundamentals of digital imaging - POONAM.pptxPoonamRijal
 
Lies and Myths in InfoSec - 2023 Usenix Enigma
Lies and Myths in InfoSec - 2023 Usenix EnigmaLies and Myths in InfoSec - 2023 Usenix Enigma
Lies and Myths in InfoSec - 2023 Usenix EnigmaAdrian Sanabria
 
ppt penjualan berbasis online omset.pptx
ppt penjualan berbasis online omset.pptxppt penjualan berbasis online omset.pptx
ppt penjualan berbasis online omset.pptxHizkiaJastis
 
Industry 4.0 in IoT Transforming the Future.pptx
Industry 4.0 in IoT Transforming the Future.pptxIndustry 4.0 in IoT Transforming the Future.pptx
Industry 4.0 in IoT Transforming the Future.pptxMdRafiqulIslam403212
 
Soil Health Policy Map Years 2020 to 2023
Soil Health Policy Map Years 2020 to 2023Soil Health Policy Map Years 2020 to 2023
Soil Health Policy Map Years 2020 to 2023stephizcoolio
 

Recently uploaded (15)

Operations Data On Mobile - inSis Mobile App - Sample Screens
Operations Data On Mobile - inSis Mobile App - Sample ScreensOperations Data On Mobile - inSis Mobile App - Sample Screens
Operations Data On Mobile - inSis Mobile App - Sample Screens
 
Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...
Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...
Generative AI Rennes Meetup with OVHcloud - WAICF highlights & how to deploy ...
 
A Gentle Introduction to Text Analysis :)
A Gentle Introduction to Text Analysis :)A Gentle Introduction to Text Analysis :)
A Gentle Introduction to Text Analysis :)
 
itc limited word file.pdf...............
itc limited word file.pdf...............itc limited word file.pdf...............
itc limited word file.pdf...............
 
IIBA Adl - Being Effective on Day 1 - Slide Deck.pdf
IIBA Adl - Being Effective on Day 1 - Slide Deck.pdfIIBA Adl - Being Effective on Day 1 - Slide Deck.pdf
IIBA Adl - Being Effective on Day 1 - Slide Deck.pdf
 
Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...
 
Business Analytics _ Confidence Interval
Business Analytics _ Confidence IntervalBusiness Analytics _ Confidence Interval
Business Analytics _ Confidence Interval
 
Tips to Align with Your Salesforce Data Goals
Tips to Align with Your Salesforce Data GoalsTips to Align with Your Salesforce Data Goals
Tips to Align with Your Salesforce Data Goals
 
AWS Identity and access management for users
AWS Identity and access management for usersAWS Identity and access management for users
AWS Identity and access management for users
 
fundamentals of digital imaging - POONAM.pptx
fundamentals of digital imaging - POONAM.pptxfundamentals of digital imaging - POONAM.pptx
fundamentals of digital imaging - POONAM.pptx
 
Lies and Myths in InfoSec - 2023 Usenix Enigma
Lies and Myths in InfoSec - 2023 Usenix EnigmaLies and Myths in InfoSec - 2023 Usenix Enigma
Lies and Myths in InfoSec - 2023 Usenix Enigma
 
ppt penjualan berbasis online omset.pptx
ppt penjualan berbasis online omset.pptxppt penjualan berbasis online omset.pptx
ppt penjualan berbasis online omset.pptx
 
Electricity Year 2023_updated_22022024.pptx
Electricity Year 2023_updated_22022024.pptxElectricity Year 2023_updated_22022024.pptx
Electricity Year 2023_updated_22022024.pptx
 
Industry 4.0 in IoT Transforming the Future.pptx
Industry 4.0 in IoT Transforming the Future.pptxIndustry 4.0 in IoT Transforming the Future.pptx
Industry 4.0 in IoT Transforming the Future.pptx
 
Soil Health Policy Map Years 2020 to 2023
Soil Health Policy Map Years 2020 to 2023Soil Health Policy Map Years 2020 to 2023
Soil Health Policy Map Years 2020 to 2023
 

PGQL: A Language for Graphs

  • 1. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle Ask TOM Office Hours: A Language for Graphs: PGQL Albert Godfrind, Solutions Architect @agodfrin Oskar Van Rest @oskarvanrest Jean Ihm, Product Manager @JeanIhm
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | AskTOM sessions on property graphs • Today’s is the fifth session on property graphs – February’s session introduced Property Graphs – March's session explained how to model graphs from relational data – May's session explained how to perform graph analytics – August's session showed how we could view graphs – In case you missed them, recordings are available at the URL above • Today’s topic: PGQL: A language for Graphs • Visit the Spatial and Graph landing page to view recordings; submit feedback, questions, topic requests; view upcoming session dates and topics; sign up 2 https://devgym.oracle.com/pls/apex/dg/office_hours/3084
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 3 The Story So Far …
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Big Data Spatial and Graph • Available for Big Data platform/BDCS – Hadoop, HBase, Oracle NoSQL • Supported both on BDA and commodity hardware – CDH and Hortonworks • Database connectivity through Big Data Connectors or Big Data SQL • Included in Big Data Cloud Service Oracle Spatial and Graph • Available with Oracle 18c/12.2/DBCS • Using tables for graph persistence • Graph views on relational data • In-database graph analytics – Sparsification, shortest path, page rank, triangle counting, WCC, sub graphs • SQL queries possible • Included in Database Cloud Service 4 Graph Product Options
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Graph Storage Management 5 Architecture of Property Graph Graph Analytics Blueprints/Tinkerpop/Gremlin REST/WebService APIs Java,Groovy,Python,… Scalable and Persistent Storage Oracle NoSQL Database Oracle RDBMS Apache HBase What we focus on now Parallel In-Memory Graph Analytics pgql> SELECT ...
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | • What is a graph? – Data model representing entities as vertices and relationships as edges – Optionally including attributes • Flexible data model – No predefined schema, easily extensible – Particularly useful for sparse data • Enabling new kinds of analytics – Overcoming limitations in relational technology 6 Graph Data Model E A D C B F
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Graph Analysis for Business Insight 7 Identify Influencers Discover Graph Patterns in Big Data Generate Recommendations
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 8 Executing PGQL
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Invoking Graph Analytics 1. Get an in-memory analyst 2. Read the graph from the data store into memory 3. Run analytics and execute PGQL statements 9 instance = Pgx.getInstance(); session = instance.createSession(); analyst = session.createAnalyst(); pg = session.readGraphWithProperties(...) analyst.pageRank(pg,...) pg.queryPgql ("SELECT ... MATCH ... WHERE ...")
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Using the Groovy shell 10 pgx> pg.queryPgql(" pgx> SELECT x.name, y.name pgx> MATCH (x) -[:leads]-> (y) pgx> ORDER BY x.name, y.name pgx> ").print() +----------------------------------------+ | x.name | y.name | +----------------------------------------+ | Bobby Murphy | Snapchat | | Ertharin Cousin | World Food Programme | | Evan Spiegel | Snapchat | | Google | Nest | | Jack Ma | Alibaba | | Jeff Bezos | Amazon | | Pony Ma | Tencent | | Pope Francis | The Vatican | | Tony Fadell | Nest | +----------------------------------------+
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Running PGQL queries • Execute a PGQL query: • Print the results: • Iterate through the results: • Close the result set: 11 rs = pg.queryPgql("SELECT ... MATCH ... WHERE ...") rs.print() // prints all results rs.print(10) // prints the first 10 results for (PgqlResult result : rs) { String movie_title = result.getString("m.title"); String movie_budge = result.getFloat("m.budget"); ... } rs.close()
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Using Bind Variables • Much like JDBC: use "?" for variable markers. • Prepare the Statement: • Set bind values • Execute prepared statement 12 stmt = pg.preparePgql("SELECT ... MATCH ... WHERE ...") stmt.setString(1, "Alibaba") // first bind variable has index 1 stmt.setInt(2, 100) stmt.setDouble(3, 2898.10) ... rs = stmt.executeQuery()
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | • Open Source • Originally for biological research • Now a general platform for complex graph analysis and visualization • Desktop / Pure Java • Extensible via Plug-ins • Also Javascript library (cytoscape.js) 13 http://www.cytoscape.org
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Type the query or load from a file Select the properties needed
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 15 Deep Dive into PGQL
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | PGQL – Property Graph Query Language 16 SELECT p2.name AS friend_of_friend FROM facebook_graph MATCH (p1:Person) -/:friend_of{2}/-> (p2:Person) GROUP BY .. ORDER BY .. LIMIT .. OFFSET .. Example query:• Core Features – SQL-like syntax • SELECT .. FROM .. WHERE .. • Grouping and aggregation: GROUP BY, COUNT, AVG, MIN, MAX, SUM • Sorting: ORDER BY, ASC, DESC – Graph pattern matching • Define a high-level pattern and match all the instances in the data graph – Recursive path expressions • Often recursive in nature – E.g. can I reach from vertex A to vertex B via some number of edges? • Use cases: detecting circular cash flow (fraud detection), network impact analysis, etc.
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Example: Network Impact Analysis • How does network disruption impacts reachability between electric devices? 17 Device OPEN OPEN OPEN OPEN OPEN OPENOPEN OPEN OPEN OPEN OPEN OPEN OPEN OPEN OPENCLOSED CLOSED source deviceElectric_Network OPEN OPEN Connector Connection PATH connects_to AS (from) <-[c1]- (connector) -[c2]-> (to) WHERE c1.status = 'OPEN' AND c2.status = 'OPEN' SELECT n.nickname, COUNT(m) FROM Electric_Network MATCH (n:Device) -/:connects_to*/-> (m:Device) WHERE java_regexp_like(n.nickname, 'Regulator') AND n <> m GROUP BY n ORDER BY COUNT(m) DESC, n.nickname +--------------------------+----------+ | n.nickname | COUNT(m) | +--------------------------+----------+ | Regulator, VREG2_A | 1596 | | Regulator, VREG4_B | 1537 | | Regulator, VREG4_C | 1537 | | Regulator, HVMV_Sub_RegA | 3 | | Regulator, HVMV_Sub_RegB | 3 | +--------------------------+----------+ Query: For each ‘Regulator’ device, show number of reachable devices following only ‘OPEN’ connections. Example result
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | PGQL 1.0 Regular Path Queries Comparison to SQL 18 WITH temp(device_id, device_name) AS ( -- Anchor member: SELECT device_id, name FROM Devices WHERE name = 'Regulator, HVMV_Sub_RegB‘ UNION ALL -- Recursive member: SELECT Devices.device_id, Devices.name FROM temp, Devices, Connections conn1, Connections conn2, Connectors WHERE temp.device_id = conn1.to_device_id AND conn1.from_connector_id = Connectors.connector_id AND Connectors.connector_id = conn2.from_connector_id AND conn2.to_device_id = Devices.device_id AND temp.device_id != Devices.device_id) CYCLE device_id SET cycle TO 1 DEFAULT 0 SELECT DISTINCT device_name FROM temp WHERE cycle = 0 AND device_name <> 'Regulator, HVMV_Sub_RegB' PATH connects_to := (from) <- (connector) -> (to) SELECT y.name MATCH (x:Device) -/:connects_to*/-> (y:Device), WHERE x.name = 'Regulator, HVMV_Sub_RegB' AND x <> yPGQL SQL Query: Which devices are connected transitively to device 'Regulator, HVMV_Sub_RegB‘?
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic graph pattern matching SELECT v3.name, v3.age FROM socialNetworkGraph MATCH (v1:Person) –[:friendOf]-> (v2:Person) –[:knows]-> (v3:Person) WHERE v1.name = ‘Amber’ Query: Find all people who are known by friends of ‘Amber’. socialNetwork Graph 100 :Person name = ‘Amber’ age = 25 200:Person name = ‘Paul’ age = 30 300 :Person name = ‘Heather’ age = 27 777 :Company name = ‘Oracle’ location = ‘Redwood City’ :worksAt{1831} startDate = ’09/01/2015’ :friendOf{1173} :knows{2200} :friendOf {2513} since = ’08/01/2014’ 19 • Find all instances of a given pattern/template in the data graph
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic graph pattern matching SELECT v3.name, v3.age FROM socialNetworkGraph MATCH (v1:Person) –[:friendOf]-> (v2:Person) –[:knows]-> (v3:Person) WHERE v1.name = ‘Amber’ Query: Find all people who are known by friends of ‘Amber’. socialNetwork Graph 100 :Person name = ‘Amber’ age = 25 200:Person name = ‘Paul’ age = 30 300 :Person name = ‘Heather’ age = 27 777 :Company name = ‘Oracle’ location = ‘Redwood City’ :worksAt{1831} startDate = ’09/01/2015’ :friendOf{1173} :knows{2200} :friendOf {2513} since = ’08/01/2014’ 20 • Find all instances of a given pattern/template in the data graph
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Regular path expressions 21 • Matching a pattern repeatedly – Define a PATH expression at the top of a query – Instantiate the expression in the MATCH clause – Match repeatedly, e.g. zero or more times (*) or one or more times (+) :Person name = ‘Amber’ age = 29 100 :Person name = ‘Dwight’ age = 15 400 :Person name = ‘Paul’ age = 64 200 :Person name = ‘Retta’ age = 43 300 :Person name = ‘Peter’ age = 12 500 0 1 :likes since = ‘2016-04-04’ :likes since = ‘2016-04-04’ 2 4 3 5 7 6 :likes since = ‘2013-02-14’ :likes since = ‘2015-11-08’ :has_father :has_father :has_mother :has_mother snGraph PATH has_parent AS (child) –[:has_father|has_mother]-> (parent) SELECT x.name, y.name, ancestor.name FROM snGraph MATCH (x:Person) –/:has_parent+/-> (ancestor) , (y) -/:has_parent+/-> (ancestor) WHERE x.name = 'Peter' AND x <> y
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Regular path expressions 22 • Matching a pattern repeatedly – Define a PATH expression at the top of a query – Instantiate the expression in the MATCH clause – Match repeatedly, e.g. zero or more times (*) or one or more times (+) :Person name = ‘Amber’ age = 29 100 :Person name = ‘Dwight’ age = 15 400 :Person name = ‘Paul’ age = 64 200 :Person name = ‘Retta’ age = 43 300 :Person name = ‘Peter’ age = 12 500 0 1 :likes since = ‘2016-04-04’ :likes since = ‘2016-04-04’ 2 4 3 5 7 6 :likes since = ‘2013-02-14’ :likes since = ‘2015-11-08’ :has_father :has_father :has_mother :has_mother snGraph Result set PATH has_parent AS (child) –[:has_father|has_mother]-> (parent) SELECT x.name, y.name, ancestor.name FROM snGraph MATCH (x:Person) –/:has_parent+/-> (ancestor) , (y) -/:has_parent+/-> (ancestor) WHERE x.name = 'Peter' AND x <> y +--------+--------+---------------+ | x.name | y.name | ancestor.name | +--------+--------+---------------+ | Peter | Retta | Paul | | Peter | Dwight | Paul | | Peter | Dwight | Retta | +--------+--------+---------------+
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | SELECT, FROM, MATCH, WHERE • SELECT creates tabular projection of results – Alias names: SELECT (x.prop1 + x.prop2) / 2 AS avg_prop1_prop2 – Remove duplicates: SELECT DISTINCT x.prop • FROM and MATCH to specify the graph and the pattern to match on it – Example: FROM g MATCH (n) -[e]-> (m) • WHERE (optional) contains a filter expression: – The filter expression typically involves properties of vertices/edges defined in the MATCH clause • e.g. WHERE m.budget > 1000000 AND m.budget < 2000000 AND … 23 Operator type Operator Example PGQL Arithmetic +, -, *, /, % 1 + 1 Relational =, <>, <, >, <=, >= 3 < 4 Logical AND, OR, NOT true AND NOT false
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Patterns, labels, regular expressions 24 Syntax Description -/:lbl/-> Matches if there exists a path that connects the source and destination by one match of the given pattern -/:lbl*/-> Matches if there exists a path that connects the source and destination by zero or more matches of the given pattern -/:lbl+/-> Matches if there exists a path that connects the source and destination by one or more matches of the given pattern -/:lbl?/-> Matches if there exists a path that connects the source and destination by zero or one matches of the given pattern -/:lbl{2}/-> Matches if there exists a path that connects the source and destination by exactly 2 matches of the given pattern -/:lbl{2,}/-> Matches if there exists a path that connects the source and destination by at least 2 matches of the given pattern -/:lbl{2,3}/-> Matches if there exists a path that connects the source and destination by at least 2 and at most 3 (inclusive) matches of the given pattern -/:lbl{,3}/-> Matches if there exists a path that connects the source and destination by at least 0 and at most 3 (inclusive) matches of the given pattern Syntax Description (v1) Match vertex v1 -[e1]-> Match outgoing edge e1 <-[e1]- Match incoming edge e1 -[e1]- Match incoming or outgoing edge e1 () Match anonymous vertex -> <- - Match anonymous outgoing/incoming/any-directional edge (v1:lbl1|lbl2) Match vertex v1 with label lbl1 or lbl2 -[:lbl1]-> Match anonymous outgoing edge with label lbl1
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Grouping and aggregation • GROUP BY creates groups of intermediate solutions • COUNT, MIN, MAX, SUM, AVG to compute aggregations over groups of solutions – Use DISTINCT to eliminate duplicates before aggregation • E.g. COUNT(DISTINCT n.name) – Omit GROUP BY to aggregate over the entire set of solutions (returns a single row) • HAVING filters entire groups of solutions • E.g. HAVING COUNT(*) > 10 25 SELECT m.title, MAX(e.time) FROM "Movies Graph" MATCH (m) <-[e:click]- () WHERE m.type = 'movie' GROUP BY m Query: “for each movie, return the time of the most recent click” +---------------+---------------------+ | m.title | MAX(e.time) | + --------------+---------------------+ | "Yes Man" | 2011-08-25T20:19:40 | | "Match Point" | 2010-12-17T02:42:32 | +---------------+---------------------+
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | ORDER BY, LIMIT, OFFSET • ORDER BY – Sort result ascendingly (default): ORDER BY n.prop ASC, … – Sort result descendingly: ORDER BY n.prop DESC, … • LIMIT and OFFSET – For returning the “top-k” results or for “pagination” of results • E.g. OFFSET 200 LIMIT 100 returns results 200 to 300 26 200100 500 300 400 type : ‘movie’ title : ‘Match Point’ type : ‘customer’ first_name : ‘Iksana’ type : ‘movie’ title : ‘Yes Man’ type : ‘customer’ first_name : ‘Maria’ type : ‘customer’ first_name : ‘Franklin’ click 0 click 1 click 2 click 3 time : 2011-01-01T20:57:21 time : 2010-12-17T02:42:32 time : 2011-08-25T20:19:40 time : 2012-09-29T02:49:09 Movies Graph SELECT n.first_name FROM "Movies Graph" MATCH (n) WHERE n.type = 'customer' ORDER BY n.first_name LIMIT 2 +--------------+ | n.first_name | +--------------+ | Franklin | | Iksana | +--------------+ Query: “order customers by first name and return first two results”
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | PGQL data types in the In-Memory Analyst (PGX) (note: for PGQL-to-SQL, the available data types correspond to those in the RDBMS) 27 Data type Name in PGX config Example PGQL literal Implicitly converts to (e.g. integer + long => LONG) STRING string 'Franklin' INTEGER integer - LONG, FLOAT, DOUBLE LONG long 2000 FLOAT, DOUBLE FLOAT float - DOUBLE DOUBLE double 1.95 BOOLEAN boolean true DATE local_date (note: don’t use deprecated date) DATE '2017-08-18' TIME time TIME '20:15:00' TIME WITH TIME ZONE TIMESTAMP timestamp TIMESTAMP '2017-08-18 20:15:00' TIMESTAMP WITH TIME ZONE TIME WITH TIME ZONE time_with_timezone TIME '20:15:00+08' TIME TIMESTAMP WITH TIME ZONE timestamp_with_timezone TIMESTAMP '2017-08-18 20:15:00+08' TIMESTAMP
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Explicit type conversion (CAST) 28 • Convert from string: – CAST('true' AS BOOLEAN) => true – CAST('2.50' AS DOUBLE) => 2.50 – CAST('2017-08-18' AS DATE) => DATE '2017-08-18‘ • Convert to string: – CAST(true AS STRING) => 'true' – CAST(2.50 AS STRING) => '2.50' – CAST(DATE '2017-08-18' AS STRING) => '2017-08-18' • Narrowing numeric conversion – CAST(1.2 AS INTEGER) => 1 • Extract date or time portion from a timestamp: – CAST(TIMESTAMP '2017-08-18 20:15:00' AS DATE) => DATE '2017-08-18' – CAST(TIMESTAMP '2017-08-18 20:15:00' AS TIME) => TIME '20:15:00' • Create a timestamp from a date or a time: – CAST(DATE '2017-08-18' AS TIMESTAMP) => TIMESTAMP '2017-08-18 00:00:00' – CAST(TIME '20:15:00' AS TIMESTAMP) => TIMESTAMP '2018-03-19 20:15:00' It takes the current date to create a timestamp
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Built-in functions 29 Function Description Return type id(vertex/edge) get the identifier of a vertex or edge exact numeric / string has_label(vertex/edge, lbl) returns true if the vertex/edge has the label; false otherwise boolean labels(vertex) returns the labels of a vertex set<string> label(edge) returns the label of an edge string all_different(value1, value2, value3, …) returns true if the values are all different, e.g. all_different(1, 5, 2)  true e.g. all_different(1, 5, 1)  false boolean in_degree(vertex) get outgoing number of edges exact numeric out_degree(vertex) get incoming number of edges exact numeric java_regexp_like(string, pattern) returns whether the string matches the pattern1 boolean 1 see https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html • Use all_different to avoid explosion of non-equality constraints: SELECT COUNT(*) MATCH (p1:Person) -[:likes]-> (friend:Person) , (p2:Person) -[:likes]-> (friend) , (p3:Person) -[:likes]-> (friend) WHERE p1 <> p2 AND p1 <> p3 AND p2 <> p3 SELECT COUNT(*) MATCH (p1:Person) -[:likes]-> (friend:Person) , (p2:Person) -[:likes]-> (friend) , (p3:Person) -[:likes]-> (friend) WHERE all_different(p1, p2, p3)
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | • EXISTS tests for the existence of a pattern, given the already obtained bindings EXISTS subqueries 30 SELECT DISTINCT friendOfFriend.name FROM g MATCH (a:Person) –[:friend_of]-> () –[:friend_of]-> (friendOfFriend) WHERE a.name = 'Peter' AND NOT EXISTS ( SELECT * MATCH (a) –[:friend_of]-> (friendOfFriend) ) SELECT friendOfFriend.name MATCH (a:Person) –/:friend_of{2}/-> (friendOfFriend) WHERE a.name = 'Peter' Query: “Find friends of friends of Peter” More concise way of expressing the query • Instead of using SELECT DISTINCT it’s sometimes faster to test for path existence using -/../-> :
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | EXISTS subquery in PATH expression 31 PATH calls_but_no_global_write AS (:Function) –[:calls]-> (dst:Function) WHERE NOT EXISTS ( SELECT * MATCH (dst) -/:calls*/-> (:Function) –[:writes]-> (:GlobalVariable) ) SELECT f2.name FROM codeBaseGraph MATCH (f1:Function) -/:calls_but_no_global_write+/-> (f2) WHERE f1.name = 'func1' Query: “In a code base, find functions that are reachable from 'func1' such that no function along the “calls path” transitively writes to a global variable”
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Scalar subqueries 32 Example query (from the LDBC graph benchmark) SELECT person.id , COUNT(*) AS messageCount , SUM((SELECT COUNT(r) MATCH (message)<-[r:replyOf]-(comment:comment)) ) AS replyCount , SUM((SELECT COUNT(l) MATCH (:person)-[l:likes]->(message)) ) AS likeCount FROM ldbcSnbGraph MATCH (tag:tag) <-[:hasTag]- (message:post|comment) , (message) -[:hasCreator]-> (person:person) WHERE tag.name = ? GROUP BY person, tag ORDER BY 1*messageCount + 2*replyCount + 10*likeCount DESC , person.id LIMIT 100 • A scalar subquery is a subquery that returns a single value (single row + single column)
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Cartesian product • Disconnected graph patterns result in Cartesian product 33 200100 500 300 400 type : ‘movie’ title : ‘Match Point’ type : ‘customer’ first_name : ‘Iksana’ type : ‘movie’ title : ‘Yes Man’ type : ‘customer’ first_name : ‘Maria’ type : ‘customer’ first_name : ‘Franklin’ click 0 click 1 click 2 click 3 time : 2011-01-01T20:57:21 time : 2010-12-17T02:42:32 time : 2011-08-25T20:19:40 time : 2012-09-29T02:49:09 Movies Graph SELECT c1.first_name, c2.first_name FROM "Movies Graph" MATCH (c1), (c2) –[:click]-> (m) WHERE c1.first_name = 'Maria' AND m.title = 'Match Point' +---------------+---------------+ | c1.first_name | c2.first_name | +---------------+---------------+ | Maria | Maria | | Maria | Iksana | | Maria | Franklin | +---------------+---------------+ +---------------+ | c2.first_name | +---------------+ | Maria | | Iksana | | Franklin | +---------------+ +---------------+ | c1.first_name | +---------------+ | Maria | +---------------+ x =
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | PGX API: execute PGQL queries and print results • Execute a PGQL query: • Print the results: 34 resultSet = pgxSession.queryPgql("SELECT ... FROM myGraph MATCH ...") // prints all results to standard output resultSet.print() // prints the first 100 results to standard output resultSet.print(100) resultSet = pgxGraph.queryPgql("SELECT ... MATCH ...") • In the Groovy shell, use triple double quotes so that it’s not necessary to escape new lines The FROM clause can be ignored when executing queries against a PgxGraph (instead of PgxSession)
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | PGQL API: iterate through results and close result set • Iterate through the result set - Java iterator way: • Iterate through the result set - JDBC way: • Close the result set: 35 for (PgxResult result : resultSet) { String movie_title = result.getString("m.title"); String movie_budget = result.getFloat("m.budget"); ... } while (resultSet.next()) { String movie_title = resultSet.getString("m.title"); String movie_budget = resultSet.getFloat("m.budget"); ... } resultSet.close()
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Prepared statements • Safeguard applications from query injection – I.e., we want to prevent applications from using string concatenation: • Injection attack: firstName = "Franklin", lastName = "Wood' OR '1' = '1" • Prepared statements also speed up query compilation – I.e. compile query once and execute it many times but with different bind values 36 String query = "SELECT n.street_address " + "WHERE (n), n.first_name = '" + firstName + "' AND n.last_name = '" + lastName + "'"); SELECT n.street_address MATCH (n) WHERE n.first_name = ? AND n.last_name = ? Question marks (?) for bind variables.
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | PGQL API: creating and executing prepared statements – Creating a prepared statement: – Setting the bind variables – Executing the prepared statement • this requires that all bind variables have a value 37 stmnt = pgxSession.preparePgql("SELECT ... WHERE ...") stmnt.setString(1, "xyz") // first bind variable has index 1 stmnt.setInt(2, 100) stmnt.setDouble(3, 2898.10) ... resultSet = stmnt.executeQuery()
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | PGQL API: prepared statements • Example: executing a prepared statement twice but with different bind values 38 stmnt = pgxGraph.preparePgql("SELECT n.street_address " + "MATCH (n) WHERE n.last_name = ? AND n.income >= ?"); stmnt.setString(1, "Wood"); stmnt.setFloat(2, 50000); resultSet1 = stmnt.executeQuery(); stmnt.setFloat(2, 100000); resultSet2 = stmnt.executeQuery(); stmnt.close(); bind values: [“Wood“, 50000] bind values: [“Wood“, 100000] Closing the statement also closes the (two) associated result sets
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Date-time data types in Java and mapping to PGQL types • Using the new Java 8 Date-Time library1 – java.time.* – New library has five main classes, one for each of the five PGQL date-time types • Note: types correspond but names differ (e.g. TIMESTAMP <--> LocalDateTime) 39 Data type Result Set API (Java) Prepared Statement API (Java) DATE LocalDate getDate(..) setDate(LocalDate) TIME LocalTime getTime(..) setTime(LocalTime) TIMESTAMP LocalDateTime getTimestamp(..) setTimestamp(LocalDateTime) TIME WITH TIME ZONE OffsetTime getTimeWithTimezone(..) setTimeWithTimezone(OffsetTime) TIMESTAMP WITH TIME ZONE OffsetDateTime getTimestampWithTimezone(..) setTimestampWithTimezone(OffsetDateTime) 1 Java SE 8 Date and Time - http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html alternatively, access a date/time/timestamp as a java.util.Date through getLegacyDate(..)
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 40 Graph Query (PGQL) In-memory Analyst / PGX • Extreme performance, especially for analytical queries • Can combine graph algorithms with graph queries • Efficient property update through API (topology update only through Delta Update) Oracle RDBMS In-memory Analyst (PGX) Delta Update - Synchronizes an in-memory - graph snapshot with graph - changes from RDBMS - Every x seconds/minutes/hours - or upon request /* find friends of friends of Clara */ SELECT fof.name FROM myGraph MATCH (p:Person) -/:knows{2}/-> (fof:Person) WHERE p.name = 'Charles' /* find friends of friends of Clara */ SELECT fof.name FROM myGraph MATCH (p:Person) -/:knows{2}/-> (fof:Person) WHERE p.name = 'Thomas' /* find friends of friends of Clara */ SELECT fof.name FROM myGraph MATCH (p:Person) -/:knows{2}/-> (fof:Person) WHERE p.name = 'Clara' RDBMS (PGQL-to-SQL) - Schema-less (the graph is stored as triples) - Efficient property and topology update through API/SQL - Can query very large data sets that don’t fit in the memory of a single machine Transactional graph query PGX RDBMS Analytical graph query PGQL in Oracle Spatial and Graph (OSG)
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 41 Resources
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle OpenWorld and Code One 2018 • Oracle‘s flagship conference with expanded developer content • Graph sessions and demos will include: – Introduction to Graph Analytics and Graph Cloud Service – How to Analyze Data Warehouse Data as a Graph – Anomaly Detection with Graph Analytics – Build Serverless Big Data and Graph Visualization Web Applications using Spring Data and Core Java (Tom Sawyer Software) – Graph Query Language for Navigating Complex Data – Extend BI/DW by Modeling a Star Schema as a Property Graph in Oracle Database 12.2 – When Graphs Meet Machine Learning – Analyzing Blockchain and Bitcoin Transaction Data as Graphs • View full list at tinyurl.com/SpatialGraphOOW18 oracle.com/code-one | October 21-25, San Francisco, CA
  • 43. Analytics and Data Summit All Analytics. All Data. No Nonsense. March 12 – 14, 2019 Formerly called the BIWA Summit with the Spatial and Graph Summit Same great technical content…new name! www.AnalyticsandDataSummit.org
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Resources • Oracle Spatial and Graph & Big Data Spatial and Graph on OTN oracle.com/technetwork/database/options/spatialandgraph oracle.com/technetwork/database/database-technologies/bigdata-spatialandgraph – White papers, software downloads, documentation and videos • Blogs – examples, tips & tricks blogs.oracle.com/oraclespatial | blogs.oracle.com/bigdataspatialgraph • Property Graphs 101: How to Get Started with Property Graphs on the Oracle Database – Arthur Dayton, Vlamis Software https://youtu.be/QSj0zOjOAWI • YouTube channel: https://www.youtube.com/channel/UCZqBavfLlCuS0il6zNY696w • Oracle Big Data Lite Virtual Machine - a free sandbox to get started www.oracle.com/technetwork/database/bigdata-appliance/oracle-bigdatalite-2104726.html – Hands On Lab included in /opt/oracle/oracle-spatial-graph/ or http://github.com/oracle/BigDataLite/ 44
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Resources – social media and online communities • Follow the product team: @SpatialHannes, @JeanIhm, @agodfrin • Oracle Spatial and Graph SIG user groups (search “Oracle Spatial and Graph Community”) 45
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | AskTOM sessions on property graphs • Next Spatial and Graph session in November – Topic to be announced – stay tuned • View recordings, submit feedback, questions, topic requests, view upcoming session dates and topics, sign up to get regular updates 46 https://devgym.oracle.com/pls/apex/dg/office_hours/3084
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 47 Thanks for attending! See you next month. https://devgym.oracle.com/pls/apex/dg/office_hours/3084