GraphDatabases

15
General Overview GRAPH DATABASES

Transcript of GraphDatabases

Page 1: GraphDatabases

General Overview

GRAPH DATABASES

Page 2: GraphDatabases

DATABASE MODELS

Aggregate Model

Column Family

Graph Model

Key/ValueDocument

NO-SQLDatabase

Database

Relational Model

SQLDatabase

Page 3: GraphDatabases

RELATIONAL MODEL

• Designed to codify paper forms and tabular structures.

• Lack Relationships.

• Index Lookup adjacency.

• Use the standard query language (SQL)

• Rigid Models. Schema-Dependent

Page 4: GraphDatabases

DOCUMENT MODEL

• Stores a set of disconnected documents.

• Lacks the capability to describe relationships, between documents.

• Document can still be connected through out-of band ways.

• Index Look up adjacency.

• Somewhat Flexible – Less Dependent on a Schema.

Page 5: GraphDatabases

GRAPH MODEL

• Set of Vertices and Edges

• Property Graph, a Richer Model

• Relationships are First Class-Citizens

• Index Free Adjacency

• Simple and Expressive Models. White Board Friendly

• Graph Database exposes graph model with Create, Read, Update, and Delete capabilities.

Page 6: GraphDatabases

CONNECTED DATA EXAMPLE

Page 7: GraphDatabases

• Who are Bob’s Friends?

• Who are friends with Bob?

• Who are the friends of Bob’s friends?

SOCIAL NETWORK WITH RELATIONAL MODEL

Who are the friends of the

friends of Bob’s friends?

Page 8: GraphDatabases

SOCIAL NETWORK WITH DOCUMENT MODEL

• Who are Bob’s Friends? Expensive Traversal (no index free adjacency)

• Who are friends with Bob? Scan the whole dataset… Add a friend_by relationship

Increased write latency

Increased Disk Storage

Expensive Traversal (no index free adjacency)

Managing Relationships

Is always the Application

Responsibility

Page 9: GraphDatabases

SOCIAL NETWORK WITH GRAPH MODEL

• In non graph world, data is implicitly connected. Data is stored as segregated data.

• In a graph world, data is inherently connected. Data is stored as connected data.

Page 10: GraphDatabases

SOCIAL NETWORK WITH GRAPH MODEL

• Follow the path to find the answer.

• Add more Aspects to the graph.

• Order of Complexity O(log n)

• Recommend Products ?

• Fraudulence Detection?

Page 11: GraphDatabases

TYPICAL GRAPH USE CASES

• Social Networks

• Recommendations

• Authorization and Access Control

• Bioinformatics

• Geo

Page 12: GraphDatabases

CYPHER QUERY LANGUAGE

START board = node : board (board_name = 'South Coast Control') ,

station = node : graphnode (long_name = 'Waterfall')

RETURN board, station, stopRETURN stop.Name AS names

WHERE stop.Name <> 'WFL8'

MATCH (board) - [ : contains_stop] -> (station) - [ : connects_to | running_time * 1..2 ] - ( stop )

, COUNT (stop) AS stop_countORDER BY stop_count DESC

LIMIT 100

Page 13: GraphDatabases

TRAVERSAL APIS

TraversalDescription description = traversalDescription()

. relationships ( RelTypes.RunningTime, Direction.OUTGOING )

. evaluator ( Evaluators.excludeStartPosition() );

. relationships (RelTypes.ConnectsTo, Direction.OUTGOING )

. breadthFirst ( )

Page 14: GraphDatabases

KEY TIPS

• Graph model could be the best way to represent a lot of problems, yet not always the best way to solve all of these problems.

• Relational Model is not always the Right Answer, and not always the Wrong Answer either.