a game of hierarchies - microsoft...a game of hierarchies sql server 2017 graph db introduction...
TRANSCRIPT
![Page 2: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/2.jpg)
Introduction
Markus Ehrenmüller-JensenBusiness Intelligence Architect
SQL Server 2005 – 2017BI DeveloperDatabase DeveloperDatabase Admin
@MEhrenmueller/markus-ehrenmueller
AGameOfHierarchies.wordpress.com
![Page 3: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/3.jpg)
Demo Samples
Points-of-Interest (POI)Grouped by region, continent & worlds
With routes between
Recipe („A Feast of Ice and Fire“)Ingredients & meals
Family-TreeFemale & male ancestores
AGameOfHierarchies.wordpress.com
![Page 4: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/4.jpg)
Episodes
Modelling hierarchies
What is a graph?
How can I use it?
How can I use it with SQL Server 2017?
![Page 5: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/5.jpg)
Episodes
Modelling hierarchies
What is a graph?
How can I use it?
How can I use it with SQL Server 2017?
![Page 6: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/6.jpg)
Episode “Modelling”
Several columns in one table (denormalized)
Several tables (normalized)
Self-joining table
Materialized path
HierarchyID
SQL GraphDB
![Page 7: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/7.jpg)
Episodes
Modelling hierarchies
What is a graph?
How can I use it?
How can I use it with SQL Server 2017?
![Page 8: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/8.jpg)
Graph
Eg. POI, Route
Nodes (POI) are connected via Edges (Route)
AdvantageNo redundancy
Unlimited in the amount of levels
All kind of graphs (not only hierarchies), eg. many-to-many
DisadvantageJoins needed
Complex queries (Loops, recursive CTE) vs. CQL
![Page 9: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/9.jpg)
Graph
Node NodeEdge
![Page 10: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/10.jpg)
Graph
Robis father ofEddard
![Page 11: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/11.jpg)
Graph
WinterfellCastle
CerwynRoute
(Miles)
White Harbor
Moat Cailin
![Page 12: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/12.jpg)
(UN-)Directed Graph
Undirected Directed
Rob
Eddard Catlyn
Winter-fell
Castle Cerwyn
White Harbor
Moat Cailin
![Page 13: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/13.jpg)
(A-)Cyclic Graph
Cyclic Acyclic
Rob
Eddard Catlyn
Winter-fell
Castle Cerwyn
White Harbor
Moat Cailin
![Page 14: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/14.jpg)
(Un-)Connected Graph
Unconnected Connected
Rob
Eddard Catlyn
Winter-fell
Castle Cerwyn
White Harbor
Moat Cailin
![Page 15: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/15.jpg)
(Un-)Weighted Graph
Weighted Unweighted
Rob
Eddard Catlyn
Winter-fell
Castle Cerwyn
White Harbor
Moat Cailin
5
7
![Page 16: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/16.jpg)
Properties
NodesAdjectiveEg. Birthdate
EdgesMeasureEg. Amount, Cost, Miles, …
![Page 17: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/17.jpg)
Episodes
Modelling hierarchies
What is a graph?
How can I use it?
How can I use it with SQL Server 2017?
![Page 18: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/18.jpg)
Use cases for graphs
Social networksNode: PeopleEdge: Interactions
Recommendation enginesNodes: Users & productsEdge: Purchases, browsing, rating, …
GeospatialRoute optimization
Internet of ThingsNetwork & connections of “Things”
Page Rank
![Page 19: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/19.jpg)
Episodes
Modelling hierarchies
What is a graph?
How can I use it?
How can I use it with SQL Server 2017?
![Page 20: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/20.jpg)
What is SQL Server Graph DB
Integrated in SQL Engine, Tooling & Eco-SystemGraphs can be combined with “normal” tablesColumnStore, Machine Learning, HA, …SSMS (“Graph Tables”), Backup & Restore, …Dynamic Data Masking, Row Level Security, …Will be available for SQL on Linux as well
One Graph per database
Graph := collection of nodes & edges
Define & create graphsVia nodes-tables & edge-tables
Query Language ExtensionMATCH
![Page 21: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/21.jpg)
Nodes
Entities, vertices
Similar to a row (RDBMS) or document (DocumentDB)
Typically a nounsEg. Eddard, King’s Landing, Ale
Must contain at least one column
![Page 22: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/22.jpg)
Nodes
CREATE TABLE <MyNode>(
…
) AS NODE;
graph_id, $node_id
![Page 23: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/23.jpg)
Edges
Graphs, relationshipsConnect nodes
Similar to relationship (RDBMS)Can model many-to-many relationships
Might have attributes
Typically an verbEg. is father of, connects, part of, likes
Can connect nodes multiple times
![Page 24: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/24.jpg)
Edges
CREATE TABLE <MyEdge>(
…
) AS EDGE;
graph_id, from_obj_id, from_id, to_obj_id, to_id, $edge_id, $from_id, $to_id
![Page 25: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/25.jpg)
Limitations and Known Issues
Pre ANSI-92 syntax for joins
Complex traverses not supported via MATCHUse loops or recursive CTEs for transitive closure, shortest path or page rank
Not allowed as Node or EdgeLocal or global temporary, Table types and table variables , system-versioned temporal tables, memory optimized tables, stretching, external table (Polybase)
No UPDATE for $from_id & $to_idInsert the new edge pointing to new nodes and delete the previous one
Cross database queries are not supported
![Page 26: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/26.jpg)
Semantic Query
Pattern matching
Multi-hop queriesInternally represented as JOINs
Cypher Query Language (CQL)Created by Neo Technology for Neo4j, open source since 2015
Declarative query language
MATCH-extension to SELECT/WHERE
GremlinAPI for CosmosDB
![Page 27: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/27.jpg)
Cypher Query Language (CQL)
Father Childis father of
Father-(IsFatherOf)->Child
![Page 29: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/29.jpg)
What John SnoWknows
nothing (Source: Ygritte)
![Page 30: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/30.jpg)
Resources
Using GROUP BY with ROLLUP, CUBE, and GROUPING SETShttps://technet.microsoft.com/en-us/library/bb522495(v=sql.105).aspx
Itzik Ben-Gan (2015), T-SQL Querying, Microsoft Presshttps://www.microsoftpressstore.com/store/t-sql-querying-9780735685048
Steve Stedman (2015), Advanced CTEhttp://stevestedman.com/2015/06/24-hours-of-pass-advanced-cte-presenation/
Graph DB Architecturehttps://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-architecture
Graph data processing with SQL Server 2017 and Azure SQL DB https://www.youtube.com/watch?v=SdKwDhe5J4M
![Page 31: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/31.jpg)
Hodor?
Markus Ehrenmüller-JensenBusiness Intelligence Architect
SQL Server 2005 – 2017BI DeveloperDatabase DeveloperDatabase Admin
@MEhrenmueller/markus-ehrenmueller
AGameOfHierarchies.wordpress.com
![Page 32: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/32.jpg)
Just like Jimi Hendrix …
We love to get feedback
Please complete the session feedback forms
![Page 33: A Game of Hierarchies - Microsoft...A Game of Hierarchies SQL Server 2017 Graph DB Introduction Markus Ehrenmüller-Jensen Business Intelligence Architect SQL Server 2005 –2017 BI](https://reader034.vdocument.in/reader034/viewer/2022042405/5f1d90f063438250670c4a0b/html5/thumbnails/33.jpg)
SQLBits - It's all about the community...
Please visit Community Corner, we are trying this year to get more people to learn about the SQL Community, equally if you would be happy to visit the community corner we’d really appreciate it.