database a grafo - introduzionedatabase a grafo - introduzione data - padova. relatori fabio lamanna...

33
Database a grafo - Introduzione DATA - PADOVA

Upload: others

Post on 10-Jul-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Database a grafo - Introduzione

DATA - PADOVA

Page 2: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

RELATORI

Fabio Lamanna Consulente @ LARUS Business Automation

Page 3: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

AGENDA • Neo4j - Fabio Lamanna

• Il database a grafo per ripensare i dati e le loro relazioni

• Use Cases • Digital Humanities • Antares Vision • Amica Pathfinder • Cerved Graph4You

• DEMO • Importare, analizzare e visualizzare dati a grafo

• Q&A

Page 4: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Why graphs?

Page 5: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

The world is a graph – everything is connected

• people, places, events • companies, markets • countries, history, politics • sciences, art, teaching • technology, networks, machines,

applications, users • software, code, dependencies,

architecture, deployments • criminals, fraudsters and their behavior

Page 6: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Piccolo il mondo!

Page 7: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

D. J. Watts and S .H. Strogatz. Collective dynamics of ‘small-world’ networks. Nature, 393: 440, 1998.

Small-World Networks

Page 8: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Random vs Scale-free Networks

Page 9: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Random vs Scale-free Networks

A.-L. Barabási and R. Albert. Emergence of scaling in random networks. Science, 286:509-512, 1999.

Page 10: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

We depend from connections

Page 11: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

We depend from connections

Page 12: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Neo4j Fundamentals

• Nodes

• Relationships

• Properties

• Labels

Page 13: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Car

Property Graph Model Components

Nodes • Represent the objects in the

graph • Can be labeled

Person Person

Page 14: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Car

DRIVES

Property Graph Model Components

Nodes •Represent the objects in the graph •Can be labeled

Relationships • Relate nodes by type and

direction

LOVES

LOVES

LIVES WITH

OWNS

Person Person

Page 15: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Car

DRIVES

name: “Dan” born: May 29, 1970

twitter: “@dan”

name: “Ann” born: Dec 5,

1975

since: Jan 10, 2011

brand: “Volvo”

model: “V70”

Property Graph Model Components

Nodes •Represent the objects in the graph •Can be labeled

Relationships •Relate nodes by type and direction

Properties • Name-value pairs that can go on

nodes and relationships.

LOVES

LOVES

LIVES WITH

OWNS

Person Person

Page 16: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Summary of the graph building blocks

• Nodes - Entities and complex value types

• Relationships - Connect entities and structure domain

• Properties - Entity attributes, relationship qualities, metadata

• Labels - Group nodes by role

Page 17: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Whiteboard Friendliness

Easy to design and model direct representation of the model

Page 18: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Whiteboard friendliness

Page 19: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Tom Hanks Hugo Weaving

Cloud AtlasThe Matrix

Lana Wachowski

ACTED_IN

ACTED_IN ACTED_IN

DIRECTED

DIRECTED

Whiteboard friendliness

Page 20: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

name: Tom Hanks born: 1956

title: Cloud Atlas released: 2012

title: The Matrix released: 1999

name: Lana Wachowski born: 1965

ACTED_IN roles: Zachry

ACTED_IN roles: Bill Smoke

DIRECTED

DIRECTED

ACTED_IN roles: Agent Smith

name: Hugo Weaving born: 1960

Person

Movie

Movie

Person Director

ActorPerson Actor

Whiteboard friendliness

Page 21: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Whiteboard friendliness

Page 22: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Neo4j

native GraphDB

Cypher Query

Language

Developer Workbench

extensible Procedures &

Functionsschema free

Property Graph Model

Graph Visualization

Graph Storage

Neo4j is a graph database

Page 23: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Relational is simple...until it gets complicated...

Relational to Graph

32

table1 table2join-table

Page 24: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

You know relational...now consider relationships...

Relational to Graph

33

actors moviesactor_movie

Page 25: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

A pattern matching query language made for graphs

�25

Cypher

Page 26: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Pattern in our Graph Model

LOVES

Dan Ann

NODE NODERelationship

Page 27: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Cypher: Express Graph Patterns

(:Person { name:"Dan"} ) -[:LOVES]-> (:Person { name:"Ann"} )

LOVES

Dan Ann

LABEL PROPERTY

NODE NODE

LABEL PROPERTY

Relationship

Page 28: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Cypher: CREATE Graph Patterns

CREATE (:Person { name:"Dan"} ) -[:LOVES]-> (:Person { name:"Ann"} )

LOVES

Dan Ann

LABEL PROPERTY

NODE NODE

LABEL PROPERTY

Relationship

Page 29: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

Cypher: MATCH Graph Patterns

MATCH (:Person { name:"Dan"} ) -[:LOVES]-> ( whom ) RETURN whom

LOVES

Dan ?

VARIABLE

NODE NODE

LABEL PROPERTY

Relationship

Page 30: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

A social recommendation

Page 31: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

MATCH (person:Person)-[:IS_FRIEND_OF]->(friend), (friend)-[:LIKES]->(restaurant), (restaurant)-[:LOCATED_IN]->(loc:Location), (restaurant)-[:SERVES]->(type:Cuisine)WHERE person.name = 'Philip' AND loc.location='New York' AND type.cuisine='Sushi'RETURN restaurant.name

A social recommendation

Page 32: Database a grafo - IntroduzioneDatabase a grafo - Introduzione DATA - PADOVA. RELATORI Fabio Lamanna Consulente @ LARUS Business Automation . AGENDA • Neo4j - Fabio Lamanna • Il

A social recommendation