intro-to-graphs



intro-to-graphs

0 0


intro-to-graphs


On Github ukmadlz / intro-to-graphs

/ ukmadlz

Introduction to Graph Databases

Legal Disclaimer

  • © IBM Corporation 2015. All Rights Reserved.
  • The information contained in this publication is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this publication, it is provided AS IS without warranty of any kind, express or implied. In addition, this information is based on IBM’s current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this publication or any other materials. Nothing contained in this publication is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software.
  • References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this presentation may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.
  • If the text contains performance statistics or references to benchmarks, insert the following language; otherwise delete: Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon many factors, including considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve results similar to those stated here.
  • If the text includes any customer examples, please confirm we have prior written approval from such customer and insert the following language; otherwise delete: All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer.
  • Please review text for proper trademark attribution of IBM products. At first use, each product name must be the full name and include appropriate trademark symbols (e.g., IBM Lotus® Sametime® Unyte™). Subsequent references can drop “IBM” but should include the proper branding (e.g., Lotus Sametime Gateway, or WebSphere Application Server). Please refer to http://www.ibm.com/legal/copytrade.shtml for guidance on which trademarks require the ® or ™ symbol. Do not use abbreviations for IBM product names in your presentation. All product names must be used as adjectives rather than nouns. Please list all of the trademarks that you use in your presentation as follows; delete any not included in your presentation. IBM, the IBM logo, Lotus, Lotus Notes, Notes, Domino, Quickr, Sametime, WebSphere, UC2, PartnerWorld and Lotusphere are trademarks of International Business Machines Corporation in the United States, other countries, or both. Unyte is a trademark of WebDialogs, Inc., in the United States, other countries, or both.
  • If you reference Adobe® in the text, please mark the first use and include the following; otherwise delete: Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States, and/or other countries.
  • If you reference Java™ in the text, please mark the first use and include the following; otherwise delete: Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
  • If you reference Microsoft® and/or Windows® in the text, please mark the first use and include the following, as applicable; otherwise delete: Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both.
  • If you reference Intel® and/or any of the following Intel products in the text, please mark the first use and include those that you use as follows; otherwise delete: Intel, Intel Centrino, Celeron, Intel Xeon, Intel SpeedStep, Itanium, and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.
  • If you reference UNIX® in the text, please mark the first use and include the following; otherwise delete: UNIX is a registered trademark of The Open Group in the United States and other countries.
  • If you reference Linux® in your presentation, please mark the first use and include the following; otherwise delete: Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  • If the text/graphics include screenshots, no actual IBM employee names may be used (even your own), if your screenshots include fictitious company names (e.g., Renovations, Zeta Bank, Acme) please update and insert the following; otherwise delete: All references to [insert fictitious company name] refer to a fictitious company and are used for illustration purposes only.

Who am I?

Mike Elsmore

Developer Advocate

mike.elsmore@uk.ibm.com

@ukmadlz

Playing with

What are Graphs?

Graph Network Theory

https://en.wikipedia.org/wiki/Network_theory

https://en.wikipedia.org/wiki/Graph_theory

Brief Description

Storing and modeling data as vertices/nodes and the interconnected edges. Representing discrete data points as vertices and the relationships between them as edges

Vertex?

Discrete data points

Edge?

The relationship between discrete data points

Traversal

Moving between different data points in side the Graph for insights

Traversal Example

Why would you use Graphs?

Social Graphs

aka Social Networks

https://en.wikipedia.org/wiki/Social_graph https://en.wikipedia.org/wiki/Erd%C5%91s_number

Demo: http://bacon.mybluemix.net/

Recommendation Engines

Matching items to other items based on the relationships between them

Demo: http://rk-graph.mybluemix.net/

Fraud Detection

Detecting patterns that don't follow normal trends

Large Scale Relational Problems

Read queries that are likely to use a lot of memory or table lock for a prolonged time

Name a Graph Database?

Popular Graphs

Neo4j OrientDB Titan

http://db-engines.com/en/ranking/graph+dbms

What's IBM Graph?

Based on TinkerPop3

Available via IBM Bluemix

https://console.ng.bluemix.net/catalog/services/ibm-graph/

https://console.eu-gb.bluemix.net/catalog/services/ibm-graph/

How to interact with IBM Graph

  • No access to the Gremlin binary protocol
  • Via the HTTP API
  • If you can Curl or make a HTTP request you can use it

Endpoints

  • /vertices to manage vertices
  • /edges to manage edges
  • /gremlin to query with gremlin queries
  • /index to manage indexes
  • /schema to create and view all existing indexes

Vertices

Make POST, PUT, GET & DELETE queries to manipulate the vertices

https://ibm-graph-docs.ng.bluemix.net/api.html#vertex-apis

Example:

curl $GRAPHURL/vertices -X POST -H "Content-Type: application/json" -d "{ \"key1\":\"A\", \"key2\":\"B\" }"

Edges

Make POST, PUT, GET & DELETE queries to manipulate the edges

https://ibm-graph-docs.ng.bluemix.net/api.html#edge-apis

Example:

curl $GRAPHURL/edges -X POST -H "Content-Type: application/json" -d "{ \"outV'": 256, \"label\": \"knows\", \"inV\": 512 }"

Indexes

Make POST, PUT, GET & DELETE queries to manipulate the indexes

https://ibm-graph-docs.ng.bluemix.net/api.html#index-apis

Example:

curl $GRAPHURL/index?type=vertex -X POST -H "Content-Type: application/json" -d "{ \"type\": \"vertex\", \"propertyKeys'": [{\"name\": \"personName\", \"dataType\": \"String\", \"cardinality\": \"SINGLE\"}], \"indexOnly\": {\"name\": \"person\"}, \"composite\": true, \"name\": \"vByPerson\"}"

Schemas

Make POST & GET queries to manipulate the schemas

https://ibm-graph-docs.ng.bluemix.net/api.html#schema-apis

Example:

curl $GRAPHURL/schema -X POST -H "Content-Type: application/json" -d "{ \"edgeindexes\": [], \"edgelabels\": [ {\"multiplicity\":\"simple\", \"name\":\"r\"} ], \"propertykeys\": [ {\"cardinality\":\"single\", \"datatype\":\"string\", \"name\":\"c\"} ], \"vertexindexes\": [ {\"composite\":false, \"name\":\"ci\", \"propertykeys\":[ \"c\" ], \"unique\":false} ], \"vertexlabels\": [ {\"name\": \"l\"} ] }"

Gremlin

Make POST queries to manipulate your entire Graph

https://ibm-graph-docs.ng.bluemix.net/api.html#gremlin-apis

Example:

curl $GRAPHURL/gremlin -X POST -H "Content-Type: application/json" -d "{\"gremlin\": \"def g = graph.traversal(); g.V(256).out().out()\"}"

Gremlin in the machine!

And Gremlin is…?

Domain specific language based on Groovy (allows injection of Groovy & Java libraries) It's OLAP & OLTP, but IBM graph is just OLTP currently

Gremlin Docs

http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#graph-traversal-steps

Example

Example of Gremlin in Social Graphs

http://bacon.mybluemix.net/

Questions?

mike.elsmore@uk.ibm.com

@ukmadlz

© IBM Corporation 2016. All Rights Reserved.