SQL Server 2017 Graph Database Inside-Out

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

Hierarchies & Trees in SQL by Joe Celko copyright 2008.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
Computer Science 101 Database Concepts. Database Collection of related data Models real world “universe” Reflects changes Specific purposes and audience.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2015, Fred McClurg, All Rights.
Databases MIS 21. Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Denny Cherry twitter.com/mrdenny.
Visual Programing SQL Overview Section 1.
Database and Information Management Chapter 9 – Computers: Understanding Technology, 3 rd edition.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Session 1 Module 1: Introduction to Data Integrity
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Chapter 3: Relational Databases
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
Execution Plans Detail From Zero to Hero İsmail Adar.
SQL Basics Review Reviewing what we’ve learned so far…….
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Carlos Bossy Quanta Intelligence SQL Server MCTS, MCITP BI CBIP, Data Mining Real-time Data Warehouse and Reporting Solutions.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Getting started with Accurately Storing Data
Databases and DBMSs Todd S. Bacastow January
Fundamentals of DBMS Notes-1.
and Big Data Storage Systems
Learn about relations and their basic properties
Top 50 SQL Interview Questions & Answers
Joe Sack, Principal Program Manager, Microsoft
Relational Database Design
Chapter 1: Introduction
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
MongoDB Er. Shiva K. Shrestha ME Computer, NCIT
 2012 Pearson Education, Inc. All rights reserved.
NOSQL databases and Big Data Storage Systems
Translation of ER-diagram into Relational Schema
Entity Based Staging SQL Server 2012 Tyler Graham
Discrete Structures for Computer Science
1 Demand of your DB is changing Presented By: Ashwani Kumar
Accounting System Design
Introduction to Data Vault on SQL Server
Database Fundamentals
Database management concepts
Automating SSIS Design Patterns with Biml
Teaching slides Chapter 8.
Power BI for large databases
Managing Objects with Data Dictionary Views
Selected Topics: External Sorting, Join Algorithms, …
Introduction to Data Vault
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Please thank our sponsors!
What’s new with SQL Server
Accounting System Design
Data Management Innovations 2017 High level overview of DB
A gentle introduction to graph databases
Analytics in the Cloud using Microsoft Azure
Database management concepts
SSDT and Database Project Basics
Contents Preface I Introduction Lesson Objectives I-2
logical design for relational database
Databases and the MVC Model
Updating Databases With Open SQL
Triggers 7/11/2019 See scm-intranet.
Applying Data Warehouse Techniques
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Updating Databases With Open SQL
Dimension Load Patterns with Azure Data Factory Data Flows
Presentation transcript:

SQL Server 2017 Graph Database Inside-Out Raymond Sondak @raymondsondak Sep 30th 2017 SQL Server 2017 Graph Database Inside-Out

Thanks to our sponsors! Please add this slide in your presentation

Please add this slide in your presentation

Hello there… W E @raymondsondak nl.linkedin.com/in/raymondsondak | BI Architect & Specialist W www.analyticsaholic.com E raymond.sondak@analyticsaholic.com The Biml Book Business Intelligence and Data Warehouse Automation Pre-oder: Apress or Amazon

Agenda Graph theory Graph database SQL Server 2017: SQL Graph Demo Limitations

Graph Theory Definition A graph G consists of a set of vertices V and a set of edges E, where an edge is an unordered pair of vertices. G=(V, E) Example Computer Networks V = {computers} E = {{A, B} | computers A and B are networked} Social Networks V = {Alice, Bob, Chris, Daniel, ...} E = {{A, B} | A and B know each other} V = {v1, v2, v3, v4, v5} and E = {e1, e2, e3, e4, e5, e6}. Source: https://math.dartmouth.edu/archive/m38s04/public_html/intro.pdf

Graph Database Database engine that models Nodes (or Vertices) and Edges Apply Graph theory to the data model that describe data relationships Stores relations as first class citizens Answer specific problem on data relationships that ‘not easy’ to achieve using relational database

Graph Database Tweet Organization Book Sales

SQL Graph Architecture SQL Server 2017 and Azure SQL Database Database can contains graph Graph is a collection of node and edge tables A node has properties and represents an entity An edge may or may not have properties and represents a relationship between two nodes Support SQL Server technologies Source: https://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-architecture

SQL Graph objects Node Edge Source: https://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-architecture

Create Node $node_id Hex string as internal identifier -- Create NODE Author CREATE TABLE Author ( AuthorId INTEGER PRIMARY KEY , Author VARCHAR(100) ) AS NODE $node_id Unique identifier of a node in the database JSON string of object_id and bigint value Implicit creation of non-clustered index Hex string as internal identifier Internal hidden column

Create Edge $edge_id $from_id and $to_id -- Create EDGE AuthorBy CREATE TABLE [graph].[AuthoredBy] AS EDGE $edge_id Unique identifier of an edge in the database JSON string of object_id and bigint value Implicit creation of non-clustered index $from_id and $to_id $node_id of the directed relation from and to node Hex string as internal identifier Internal hidden column

MATCH clause SELECT BookTitle FROM graph.Book, graph.AuthoredBy, graph.Author WHERE MATCH(Book-(AuthoredBy)->Author) AND Author like '%Coelho%' Using search pattern to traverse the graph from one node to another via edge ASCII-art syntax (\m/) for pattern matching

Relational database to Graph database edge node node node edge

Book database as example Book database from kaggle Enrich with own generated data Relational and Graph model demo Create node and edge tables Relational database query vs Graph query Source: https://www.kaggle.com/zygmunt/goodbooks-10k

Demo setup Create book data table Create book transaction table Load source data for book data and transaction Create relational tables Load relational tables Create graph tables Load graph tables

Demo case results Case 1 Case 4 Case 3 Case 2

Graph object query JSON string SELECT $node_id ,OBJECT_ID_FROM_NODE_ID($node_id) AS ObjectId ,JSON_VALUE($node_id, '$.type') + '.' + JSON_VALUE($node_id, '$.schema') + '.' + JSON_VALUE($node_id, '$.table') + '.' + JSON_VALUE($node_id, '$.id') AS JSONValue ,[AuthorId] ,[Author] FROM [BookDB].[graph].[Author]

Some limitations Cross database queries not supported UPDATE statement not supported (INSERT and DELETE) MERGE not supported No validation on node type for edge object (use trigger) No validation on referential integrity (use trigger) Polymorphism is not supported Transitive closure is not supported Graph algorithm like shortest path is not available

Trigger - Validation CREATE TRIGGER [graph].[ValidateAuthoredBy] ON [graph].[AuthoredBy] FOR INSERT AS IF EXISTS ( SELECT 1 FROM inserted WHERE JSON_VALUE($to_id, '$.schema')<>'graph' or JSON_VALUE($to_id, '$.table')<>'Author' ) BEGIN RAISERROR('Only author can authored book',10,1) ROLLBACK TRANSACTION END GO INSERT INTO graph.AuthoredBy VALUES ( (SELECT $node_id FROM graph.Book WHERE BookId = 1), (SELECT $node_id FROM graph.Customer WHERE CustomerId = 1) );

Trigger – Referential Integrity CREATE TRIGGER [graph].[ValidateDeleteAuthor] on [graph].[Author] FOR DELETE AS IF EXISTS ( SELECT 1 FROM deleted WHERE JSON_VALUE($node_id, '$.id') IN ( SELECT JSON_VALUE($to_id, '$.id') AS nodeid FROM [graph].[AuthoredBy] UNION SELECT JSON_VALUE($from_id, '$.id') AS nodeid FROM [graph].[AuthoredOf] ) BEGIN RAISERROR('Unable to delete, edge record available',10,1) ROLLBACK TRANSACTION END DELETE FROM [BookDB].[graph].[Author] WHERE AuthorId = 1

Graph Reporting in Power BI

Summary First release product RDBMS and Graph in one product Support SQL Server technologies (security, columnstore, partitioning, HA, R Services, …) Graph objects are just tables, will works out of the box with PowerBI, SSRS, SSIS, SSAS Complement RDBMS

Reference SQL Graph overview: https://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-overview SQL Graph Architecture: https://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-architecture SQL Graph sample: https://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-sample SQL Server Blog: https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/20/graph-data-processing-with-sql-server-2017/ Force-Directed Graph Power BI Visual: https://appsource.microsoft.com/nl-nl/product/power-bi-visuals/WA104380764?src=office&tab=Overview

Please fill in the evaluations Please add this slide in your presentation