SlideShare una empresa de Scribd logo
1 de 20
So what are graph
databases pistas
at?
Aneesh Mon N
06-Nov-2019
Chennai
About Mixed-Nuts-at-Pramati
Mixed Nuts is a meetup organized by Pramati Technologies in
Chennai. Meetups and Workshops on a diverse range of tech
topics are hosted here.
Who are we? Website : https://www.pramati.com/
Blog : https://blog.imaginea.com/
About Me
Aneesh has been working with huge data sets and is proficient in
integrating, centralizing and maintaining data using database, ETL
and SOLR skills. Recently he has started exploring Graph
databases, to solve open issues of RDBMS.
LinkedIn: https://www.linkedin.com/in/aneeshmonn
Agenda
1. RDBMS Challenges
2. GraphDB and Why GraphDB?
a. Popular GraphDB’s
b. Popular Query languages for GraphDB
3. Property Graph Model
4. Neo4J
a. Neo4j Cypher & Sandbox
5. IPL Data Analysis GraphDB Vs RDBMS
6. Demo
IPL Data Analysis: GraphDB Schema
RDBMS Challenges
1. RDBMS lacks performance when the data is highly connected
a. cause a lot of joins
b. over 7 self/recursive joins, the RDMS starts to get really slow
2. RDBMS aren’t designed to capture this rich relationship and
lacks flexibility
a. don’t adapt well to change
b. fixed schema
c. addresses known problems
3. Complex Queries
a. query syntax becomes complex and large as the joins increase
GraphDB and Why GraphDB?
● GraphDB
○ designed to treat the relationships between data as equally
important to the data itself
○ intended to hold data without constricting it to a pre-defined
model
○ data is stored like we first draw it out
● Why GraphDB
○ Its connected world! There are no isolated pieces of information
○ stores connections alongside the data
○ graph databases excel at managing highly-connected data
Popular GraphDB’s
● Neo4J
● OrientDB
● Amazon Neptune
● ArangoDB
Popular Query languages for GraphDB
● Cypher: a graph query declarative language for Neo4j that
enables ad hoc and programmatic (SQL-like) access to the
graph
● GraphQL: an open-source data query and manipulation
language for APIs
● Gremlin: a graph programming language that is a part of
Apache TinkerPop open-source project
● AQL (ArangoDB Query Language): a SQL-like query language
used in ArangoDB for both documents and graphs
Property Graph Model
● Nodes
○ entities in the graph
○ can be tagged with labels, representing their different roles in your domain
○ can hold any number of attributes (key-value pairs) called properties
● Relationships
○ provide directed,
named,
semantically-
relevant connections
between two node
entities
○ has a direction, a
type, a start node,
and an end node
Neo4j
● Open-source, NoSQL, native graph database
● Provides full database characteristics, including ACID
transaction compliance
● Implements the property graph model down to the storage
level
● Uses Cypher Query Language
● Constant time traversals
● Flexible property graph schema
● Drivers for popular programming languages
Neo4j Cypher & Sandbox
● Play area for us to understand Neo4J
● https://neo4j.com/sandbox-v2/
IPL Data Analysis: RDBMS Schema
IPL Data Analysis: GraphDB Schema
Demo
Q1. List down all the matches played by
CSK.
Cypher SQL
MATCH p=()<-[:PLAYED]-(team:Team)
where team.abb="CSK"
RETURN p LIMIT 25
SELECT
s.season,
(select team_name from graphdb.teams where id=home_team_id)||' vs
'||(select team_name from graphdb.teams where id=away_team_id)
FROM
graphdb.seasons s
inner join graphdb.matches m on m.season_id=s.id
inner join graphdb.teams on
teams.id=any(ARRAY[home_team_id,away_team_id])
where teams.short_name='CSK'
Q2. Winning percentage for toss winner
season by season
Cypher SQL
match (s:Season)-[:PLAYED_IN]-(m:Match)
with s,count(m) as match_count
match (s)-[:PLAYED_IN]-(m1:Match)-[:TOSS_WON_BY]-(t:Team)
WHERE (m1)-[:WON_BY]-(t)
with s,match_count,count(m1) as win_count
return s.name,round((win_count*1.0/match_count)*100) as game_win_pct,
win_count, match_count
order by game_win_pct desc
SELECT
season as season,
round((toss_winner_winner_cnt / total_matches), 2) * 100 AS
win_percentage,
toss_winner_winner_cnt,
total_matches
FROM (
SELECT
season,
count(DISTINCT m.id) FILTER(WHERE
toss_winner_team_id=match_winner_team_id)::numeric as
toss_winner_winner_cnt,
COUNT(DISTINCT m.id)::numeric as total_matches
FROM graphdb.seasons s inner join graphdb.matches m on
m.season_id=s.id
inner join graphdb.match_win_info mw on mw.match_id=m.id
GROUP BY 1)t
order by 2 desc;
Q3. IPL Highest Partnership for a
season
Cypher SQL
Match(s:Season)<-[r:PLAYED_IN]-(m:Match)<-[b:BELONGS_TO_MATCH]-(i:Innings)-
[i2:IN_INNINGS]-(o:Over)-[b2:BELONGS_TO_OVER]-(b3:Ball)-
[s2:STRIKER|NON_STRIKER]-(p:Player)
where s.name="2013"
WITH s.name as name,m.match_id as match_id,m.name as match_name,i.innings as
innings,b3.number as ball_no,toInteger(b3.runs)+toInteger(b3.extra) as
runs,collect(p.name) as batsmans
UNWIND(batsmans) as player
WITH name,match_id,match_name,innings,ball_no,runs,player
ORDER BY player
WITH name as season,match_id,match_name,innings,ball_no,runs,COLLECT(distinct
player) as batsmans
WITH season,match_id,match_name,innings,batsmans,sum(runs) as partnership_runs
return season,match_name,batsmans,max(partnership_runs) as
max_partnership_runs
order by max_partnership_runs desc
limit 5
select
distinct
season,
partnership,
partnership_runs,
played_by
from
(
select season,
match_id,
(select short_name from graphdb.teams t inner join graphdb.matches m on
m.home_team_id=t.id and m.id=match_id limit 1)||' Vs '||(select short_name from
graphdb.teams t inner join graphdb.matches m on m.away_team_id=t.id and
m.id=match_id limit 1) as played_by,
match_innings,
partnership,
sum(runs) as partnership_runs
from
(
select season as season,mb.match_id,mb.match_innings,array_to_string((select
array_agg(player_name order by player_name) from (select
Q4. Batting Average of a Player in a
season
Cypher SQL
match (p:Player)<-[:STRIKER]-(b:Ball)-[:BELONGS_TO_OVER]->(:Over)-
[:IN_INNINGS]->(:Innings)-[:BELONGS_TO_MATCH]->(m:Match)-
[:PLAYED_IN]->(s:Season)
where s.name='2017' and p.name='V Kohli'
with s.name as season,p.name as player,sum(toInteger(b.runs)) as
total_runs,collect(b.ball_id) as ball_idså
match (b1:Ball)<-[:GOT_OUT]-(p1:Player)
where b1.ball_id in (ball_ids) and p1.name=player
with season,player,total_runs,count(b1) as out_balls
return season,player,total_runs,out_balls,total_runs*1.0/out_balls as
bat_avg
order by bat_avg desc
limit 10
select
s.season,
p.player_name,
sum(mb.runs) as total_runs,
round(case when count(distinct lb.match_id) filter (where
p.id=ANY(lb.dismiss_player_ids)) = 0 then null else
sum(mb.runs)::numeric/count(distinct mb.match_id)::numeric-count(distinct
lb.match_id) filter (where not p.id=ANY(lb.dismiss_player_ids))::numeric
end,2) as bat_avg
from
graphdb.seasons s
join
graphdb.matches m on s.id=m.season_id
join
graphdb.match_ball_wise_info mb on m.id=mb.match_id
join
graphdb.teams t on (t.id!=mb.team_id and (t.id=m.home_team_id or
t.id=m.away_team_id))
Q&A

Más contenido relacionado

La actualidad más candente

Machine Learning and GraphX
Machine Learning and GraphXMachine Learning and GraphX
Machine Learning and GraphX
Andy Petrella
 
Guug11 mashing up-google_apps
Guug11 mashing up-google_appsGuug11 mashing up-google_apps
Guug11 mashing up-google_apps
Tony Hirst
 

La actualidad más candente (9)

Machine Learning and GraphX
Machine Learning and GraphXMachine Learning and GraphX
Machine Learning and GraphX
 
Working with Complex Types in DataFrames: Optics to the Rescue
Working with Complex Types in DataFrames: Optics to the RescueWorking with Complex Types in DataFrames: Optics to the Rescue
Working with Complex Types in DataFrames: Optics to the Rescue
 
Hadoop - Apache Hive
Hadoop - Apache HiveHadoop - Apache Hive
Hadoop - Apache Hive
 
Signals from outer space
Signals from outer spaceSignals from outer space
Signals from outer space
 
Graph Database Prototyping made easy with Graphgen
Graph Database Prototyping made easy with GraphgenGraph Database Prototyping made easy with Graphgen
Graph Database Prototyping made easy with Graphgen
 
Pandas
PandasPandas
Pandas
 
Guug11 mashing up-google_apps
Guug11 mashing up-google_appsGuug11 mashing up-google_apps
Guug11 mashing up-google_apps
 
An R primer for SQL folks
An R primer for SQL folksAn R primer for SQL folks
An R primer for SQL folks
 
Interactive Graph Analytics with Spark-(Daniel Darabos, Lynx Analytics)
Interactive Graph Analytics with Spark-(Daniel Darabos, Lynx Analytics)Interactive Graph Analytics with Spark-(Daniel Darabos, Lynx Analytics)
Interactive Graph Analytics with Spark-(Daniel Darabos, Lynx Analytics)
 

Similar a Graph db - Pramati Technologies [Meetup]

Similar a Graph db - Pramati Technologies [Meetup] (20)

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...
 
The 2nd graph database in sv meetup
The 2nd graph database in sv meetupThe 2nd graph database in sv meetup
The 2nd graph database in sv meetup
 
Data Science
Data ScienceData Science
Data Science
 
Data Con LA 2022 - What's new with MongoDB 6.0 and Atlas
Data Con LA 2022 - What's new with MongoDB 6.0 and AtlasData Con LA 2022 - What's new with MongoDB 6.0 and Atlas
Data Con LA 2022 - What's new with MongoDB 6.0 and Atlas
 
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
 
Neo4j graph database
Neo4j graph databaseNeo4j graph database
Neo4j graph database
 
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-AirflowPyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
PyconZA19-Distributed-workloads-challenges-with-PySpark-and-Airflow
 
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdfXII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
 
Graph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft EcosystemGraph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft Ecosystem
 
Cypher and apache spark multiple graphs and more in open cypher
Cypher and apache spark  multiple graphs and more in  open cypherCypher and apache spark  multiple graphs and more in  open cypher
Cypher and apache spark multiple graphs and more in open cypher
 
A look under the hood at Apache Spark's API and engine evolutions
A look under the hood at Apache Spark's API and engine evolutionsA look under the hood at Apache Spark's API and engine evolutions
A look under the hood at Apache Spark's API and engine evolutions
 
Introduction to Spark Datasets - Functional and relational together at last
Introduction to Spark Datasets - Functional and relational together at lastIntroduction to Spark Datasets - Functional and relational together at last
Introduction to Spark Datasets - Functional and relational together at last
 
aRangodb, un package per l'utilizzo di ArangoDB con R
aRangodb, un package per l'utilizzo di ArangoDB con RaRangodb, un package per l'utilizzo di ArangoDB con R
aRangodb, un package per l'utilizzo di ArangoDB con R
 
GraphDatabase.pptx
GraphDatabase.pptxGraphDatabase.pptx
GraphDatabase.pptx
 
New Features in Neo4j 3.4 / 3.3 - Graph Algorithms, Spatial, Date-Time & Visu...
New Features in Neo4j 3.4 / 3.3 - Graph Algorithms, Spatial, Date-Time & Visu...New Features in Neo4j 3.4 / 3.3 - Graph Algorithms, Spatial, Date-Time & Visu...
New Features in Neo4j 3.4 / 3.3 - Graph Algorithms, Spatial, Date-Time & Visu...
 
Neo4j: Graph-like power
Neo4j: Graph-like powerNeo4j: Graph-like power
Neo4j: Graph-like power
 
managing big data
managing big datamanaging big data
managing big data
 
Multiple graphs in openCypher
Multiple graphs in openCypherMultiple graphs in openCypher
Multiple graphs in openCypher
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
AWS November Webinar Series - Advanced Analytics with Amazon Redshift and the...
 

Más de Pramati Technologies

Más de Pramati Technologies (7)

Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati TechnologiesClojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
 
Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]
 
Adaptive Cards - Pramati Technologies
Adaptive Cards - Pramati TechnologiesAdaptive Cards - Pramati Technologies
Adaptive Cards - Pramati Technologies
 
VitaFlow | Mageswaran Dhandapani [Pramati]
VitaFlow | Mageswaran Dhandapani [Pramati]VitaFlow | Mageswaran Dhandapani [Pramati]
VitaFlow | Mageswaran Dhandapani [Pramati]
 
Typography Style Transfer using GANs | Pramati
Typography Style Transfer using GANs | Pramati Typography Style Transfer using GANs | Pramati
Typography Style Transfer using GANs | Pramati
 
Document Clustering using LDA | Haridas Narayanaswamy [Pramati]
Document Clustering using LDA | Haridas Narayanaswamy [Pramati]Document Clustering using LDA | Haridas Narayanaswamy [Pramati]
Document Clustering using LDA | Haridas Narayanaswamy [Pramati]
 
Pramati - Chennai Development Center
Pramati - Chennai Development CenterPramati - Chennai Development Center
Pramati - Chennai Development Center
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 

Graph db - Pramati Technologies [Meetup]

  • 1. So what are graph databases pistas at? Aneesh Mon N 06-Nov-2019 Chennai
  • 2. About Mixed-Nuts-at-Pramati Mixed Nuts is a meetup organized by Pramati Technologies in Chennai. Meetups and Workshops on a diverse range of tech topics are hosted here. Who are we? Website : https://www.pramati.com/ Blog : https://blog.imaginea.com/
  • 3. About Me Aneesh has been working with huge data sets and is proficient in integrating, centralizing and maintaining data using database, ETL and SOLR skills. Recently he has started exploring Graph databases, to solve open issues of RDBMS. LinkedIn: https://www.linkedin.com/in/aneeshmonn
  • 4. Agenda 1. RDBMS Challenges 2. GraphDB and Why GraphDB? a. Popular GraphDB’s b. Popular Query languages for GraphDB 3. Property Graph Model 4. Neo4J a. Neo4j Cypher & Sandbox 5. IPL Data Analysis GraphDB Vs RDBMS 6. Demo
  • 5. IPL Data Analysis: GraphDB Schema
  • 6. RDBMS Challenges 1. RDBMS lacks performance when the data is highly connected a. cause a lot of joins b. over 7 self/recursive joins, the RDMS starts to get really slow 2. RDBMS aren’t designed to capture this rich relationship and lacks flexibility a. don’t adapt well to change b. fixed schema c. addresses known problems 3. Complex Queries a. query syntax becomes complex and large as the joins increase
  • 7. GraphDB and Why GraphDB? ● GraphDB ○ designed to treat the relationships between data as equally important to the data itself ○ intended to hold data without constricting it to a pre-defined model ○ data is stored like we first draw it out ● Why GraphDB ○ Its connected world! There are no isolated pieces of information ○ stores connections alongside the data ○ graph databases excel at managing highly-connected data
  • 8. Popular GraphDB’s ● Neo4J ● OrientDB ● Amazon Neptune ● ArangoDB
  • 9. Popular Query languages for GraphDB ● Cypher: a graph query declarative language for Neo4j that enables ad hoc and programmatic (SQL-like) access to the graph ● GraphQL: an open-source data query and manipulation language for APIs ● Gremlin: a graph programming language that is a part of Apache TinkerPop open-source project ● AQL (ArangoDB Query Language): a SQL-like query language used in ArangoDB for both documents and graphs
  • 10. Property Graph Model ● Nodes ○ entities in the graph ○ can be tagged with labels, representing their different roles in your domain ○ can hold any number of attributes (key-value pairs) called properties ● Relationships ○ provide directed, named, semantically- relevant connections between two node entities ○ has a direction, a type, a start node, and an end node
  • 11. Neo4j ● Open-source, NoSQL, native graph database ● Provides full database characteristics, including ACID transaction compliance ● Implements the property graph model down to the storage level ● Uses Cypher Query Language ● Constant time traversals ● Flexible property graph schema ● Drivers for popular programming languages
  • 12. Neo4j Cypher & Sandbox ● Play area for us to understand Neo4J ● https://neo4j.com/sandbox-v2/
  • 13. IPL Data Analysis: RDBMS Schema
  • 14. IPL Data Analysis: GraphDB Schema
  • 15. Demo
  • 16. Q1. List down all the matches played by CSK. Cypher SQL MATCH p=()<-[:PLAYED]-(team:Team) where team.abb="CSK" RETURN p LIMIT 25 SELECT s.season, (select team_name from graphdb.teams where id=home_team_id)||' vs '||(select team_name from graphdb.teams where id=away_team_id) FROM graphdb.seasons s inner join graphdb.matches m on m.season_id=s.id inner join graphdb.teams on teams.id=any(ARRAY[home_team_id,away_team_id]) where teams.short_name='CSK'
  • 17. Q2. Winning percentage for toss winner season by season Cypher SQL match (s:Season)-[:PLAYED_IN]-(m:Match) with s,count(m) as match_count match (s)-[:PLAYED_IN]-(m1:Match)-[:TOSS_WON_BY]-(t:Team) WHERE (m1)-[:WON_BY]-(t) with s,match_count,count(m1) as win_count return s.name,round((win_count*1.0/match_count)*100) as game_win_pct, win_count, match_count order by game_win_pct desc SELECT season as season, round((toss_winner_winner_cnt / total_matches), 2) * 100 AS win_percentage, toss_winner_winner_cnt, total_matches FROM ( SELECT season, count(DISTINCT m.id) FILTER(WHERE toss_winner_team_id=match_winner_team_id)::numeric as toss_winner_winner_cnt, COUNT(DISTINCT m.id)::numeric as total_matches FROM graphdb.seasons s inner join graphdb.matches m on m.season_id=s.id inner join graphdb.match_win_info mw on mw.match_id=m.id GROUP BY 1)t order by 2 desc;
  • 18. Q3. IPL Highest Partnership for a season Cypher SQL Match(s:Season)<-[r:PLAYED_IN]-(m:Match)<-[b:BELONGS_TO_MATCH]-(i:Innings)- [i2:IN_INNINGS]-(o:Over)-[b2:BELONGS_TO_OVER]-(b3:Ball)- [s2:STRIKER|NON_STRIKER]-(p:Player) where s.name="2013" WITH s.name as name,m.match_id as match_id,m.name as match_name,i.innings as innings,b3.number as ball_no,toInteger(b3.runs)+toInteger(b3.extra) as runs,collect(p.name) as batsmans UNWIND(batsmans) as player WITH name,match_id,match_name,innings,ball_no,runs,player ORDER BY player WITH name as season,match_id,match_name,innings,ball_no,runs,COLLECT(distinct player) as batsmans WITH season,match_id,match_name,innings,batsmans,sum(runs) as partnership_runs return season,match_name,batsmans,max(partnership_runs) as max_partnership_runs order by max_partnership_runs desc limit 5 select distinct season, partnership, partnership_runs, played_by from ( select season, match_id, (select short_name from graphdb.teams t inner join graphdb.matches m on m.home_team_id=t.id and m.id=match_id limit 1)||' Vs '||(select short_name from graphdb.teams t inner join graphdb.matches m on m.away_team_id=t.id and m.id=match_id limit 1) as played_by, match_innings, partnership, sum(runs) as partnership_runs from ( select season as season,mb.match_id,mb.match_innings,array_to_string((select array_agg(player_name order by player_name) from (select
  • 19. Q4. Batting Average of a Player in a season Cypher SQL match (p:Player)<-[:STRIKER]-(b:Ball)-[:BELONGS_TO_OVER]->(:Over)- [:IN_INNINGS]->(:Innings)-[:BELONGS_TO_MATCH]->(m:Match)- [:PLAYED_IN]->(s:Season) where s.name='2017' and p.name='V Kohli' with s.name as season,p.name as player,sum(toInteger(b.runs)) as total_runs,collect(b.ball_id) as ball_idså match (b1:Ball)<-[:GOT_OUT]-(p1:Player) where b1.ball_id in (ball_ids) and p1.name=player with season,player,total_runs,count(b1) as out_balls return season,player,total_runs,out_balls,total_runs*1.0/out_balls as bat_avg order by bat_avg desc limit 10 select s.season, p.player_name, sum(mb.runs) as total_runs, round(case when count(distinct lb.match_id) filter (where p.id=ANY(lb.dismiss_player_ids)) = 0 then null else sum(mb.runs)::numeric/count(distinct mb.match_id)::numeric-count(distinct lb.match_id) filter (where not p.id=ANY(lb.dismiss_player_ids))::numeric end,2) as bat_avg from graphdb.seasons s join graphdb.matches m on s.id=m.season_id join graphdb.match_ball_wise_info mb on m.id=mb.match_id join graphdb.teams t on (t.id!=mb.team_id and (t.id=m.home_team_id or t.id=m.away_team_id))
  • 20. Q&A