football graph - neo4j and the premier league

Download Football graph - Neo4j and the Premier League

Post on 08-Sep-2014

31 views

Category:

Sports

11 download

Embed Size (px)

DESCRIPTION

 

TRANSCRIPT

  • In a League of their Own: Neo4j and Premiership Football Mark Needham @markhneedham

Intro to graphs When do we need a graph? Property graph model Neo4js query language The football graph Using Neo4j from .NETOutline Lets talk graphs Dancing With Michael JacksonEating BrainsYou mean these? Dancing With Michael JacksonEating BrainsNope! NodeRelationshipOk so whats a graph then? The tube The social network (graph) Complexity What are graphs good for? complexity = f(size, semi-structure, connectedness)Data Complexity Size complexity = f(size, semi-structure, connectedness)The Real Complexity Semi-Structure USER_IDFIRST_NAMELAST_NAMEEMAIL_1EMAIL_2FACEBOOK315MarkNeedhammark.needham@neotech nology.comm.h.needham@gmail.comNULLEmail: mark.needham@neotechnology.com Email: m.h.needham@gmail.com Twitter: @markhneedham Skype: mk_jnr1984TWITTER @markhneedhamCONTACTUSERSemi-StructureCONTACT_TYPESKYPE mk_jnr1984 complexity = f(size, semi-structure, connectedness)The Real Complexity Connectedness Connectedness Connectedness Densely ConnectedSemi StructuredWhen do we need a graph? Lots of join tables Densely connected? Lots of sparse tables Semi-Structured? Millions of joins per second Consistent query times as dataset grows Join Complexity and Performance Easy to evolve data model Easy to layer different types of data togetherProperties of graph databases Property Graph Data Model Nodes Used to represent entity attributes and/or metadata (e.g. timestamps, version) Key-value pairs Java primitives Arrays null is not a valid value Every node can have different propertiesNodes can have properties Whats a node? Relationships Relationships are first class citizens Every relationship has a name and a direction Add structure to the graph Provide semantic context for nodes Properties used to represent quality or weight of relationship, or metadata Every relationship must have a start node and end nodeRelationships Nodes can be connected by more than one relationshipNodes can have more than one relationship Self relationships are allowedRelationships Labels Think Gmail labels Nodes Entities Relationships Connect entities and structure domain Properties Entity attributes, relationship qualities, and metadata Labels Group nodes by roleFour Building Blocks Purposeful abstraction of a domain designed to satisfy particular application/end-user goalsModels Model QueryDesign for Queryability ModelDesign for Queryability Model QueryDesign for Queryability Declarative Pattern-Matching language SQL-like syntax Designed for graphsIntroducing Cypher ABCPatterns, patterns, everywhere ab(a) --> (b) Its all about the ASCII art! MATCH (a)-->(b) RETURN a, babThe most basic query aACTED INm(a)[:ACTED_IN]->(m) Adding in a relationship type MATCH (a)-[:ACTED_IN]->(m) RETURN a.name, m.nameaACTED INmAdding in a relationship type The football graph The football graph Find Arsenals away matches Find Arsenals away matches MATCH (team:Team)