GraphDatabases
-
Upload
nader-albert -
Category
Documents
-
view
161 -
download
0
Transcript of GraphDatabases
General Overview
GRAPH DATABASES
DATABASE MODELS
Aggregate Model
Column Family
Graph Model
Key/ValueDocument
NO-SQLDatabase
Database
Relational Model
SQLDatabase
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
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.
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.
CONNECTED DATA EXAMPLE
• 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?
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
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.
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?
TYPICAL GRAPH USE CASES
• Social Networks
• Recommendations
• Authorization and Access Control
• Bioinformatics
• Geo
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
TRAVERSAL APIS
TraversalDescription description = traversalDescription()
. relationships ( RelTypes.RunningTime, Direction.OUTGOING )
. evaluator ( Evaluators.excludeStartPosition() );
. relationships (RelTypes.ConnectsTo, Direction.OUTGOING )
. breadthFirst ( )
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.
REFERENCES
• http://www.youtube.com/watch?v=qI_g07C_Q5I
• http://shop.oreilly.com/product/0636920028246.do
• http://www.infoq.com/interviews/emil-eifrem-neo4j