sql - How is a graph database different to a graph represented in a relational database? -



sql - How is a graph database different to a graph represented in a relational database? -

i can represent graph trivially in relational database 2 tables: vertex , edge. richer construction "properties" , "labels" (in neo4j terminology) can represented more tables. have misunderstood, or graph database neo4j allow me represent not representable relationally?

i can query graph using sql, recursive subqueries if necessary, , multiple separate queries in transaction if necessary. have misunderstood, or graph query language cypher provide greater expressivity sql?

the relational model of graph stored , queried efficiently, afaik. graph database construction storage, or optimize queries, in way provides performance characteristics cannot gained relational database?

my relational database provides acid guarantees, , allows me write expressive constraints on graph info (and more constraints if break out single vertex table normalized schema). have misunderstood, or graph database provide guarantees or verify kind of correctness properties not available in relational database?

i struggling see how graph database such neo4j subset of relational model. (apologies using neo4j representative of graph databases here; it's 1 i've looked at.)

in short: graph database ⊆ relational database?

is 1 subset of other?

definitely no; both modeled on mathematical concepts of relations or graphs. both models beingness super-general, there no info content can't represent using either one. means while might differ in many syntactic sugar ways, , in way encourage model/think of info (just programming languages differ) both have same "expressive power".

what describe in question 1 way of modeling graph (vertex , edge tables). implementation of graph subset of relational can express. similarly, mock tables , rows using graph database, have chosen particular implementation - wouldn't demonstrate relational info subset of graph data.

so first insight have equal expressive power. can model in either. real question should asking why take 1 on other?

why take 1 on other?

all databases exist facilitate info access. put, store can @ data. how need @ data? there many different access patterns. design space databases in general enormous. time database makes decision, tends automatically create improve @ things, worse @ others. example, when create index in relational database, you've sped reads -- you've degraded performance of writes, because index has maintained.

so, when approaching question, "graph or relational?" - should first figure out info like, , info access patterns like. if knew things were, evaluate bunch of databases, see choices they've made, , pick 1 that's fit need. , if dbms made selection create access patterns difficult, buggy, or slow -- avoid dbms info set.

it's (partly) info access patterns

graph databases tend improve relational when info beingness stored graph, when info access pattern involves lot of graph traversal, or both. (see other reply wrote more in-depth give-and-take of why is). link there provides reply specific question: "does graph database construction storage, or optimize queries, in way provides performance characteristics cannot gained relational database?"

you say: i can query graph using sql, recursive subqueries if necessary, , multiple separate queries in transaction if necessary. -- technically true, let's take illustration see why relational might not enough. have graph (in rdbms, table of nodes, table of edges, bring together key between them). let's pick out 1 node, , want identify between 6 , 8 hops away node. here's cypher that:

match (mychosennode {id: 'foo'})-[r:relationshiptype*6..8]->(y) homecoming y;

i want see write sql. it's possible, it's hard , complicated. , perform dog, because of sheer quantity of joining you'll doing on non-trivial quantities of data.

acid

ok on acid guarantees, neo4j provides transactions acid guarantees. reply different different graph databases though, particularly ones implemented on top of hadoop/hbase. ymmv there, check fine print each database.

it true there number of features of rdbms typically won't find in graph databases, examples beingness triggers , kinds of constraints. long-time rdmbs nerd myself, i'm not happy things beingness missing, think valuable.

summary

what boils downwards me, , many other engineers work is:

what data? what access patterns?

if info graph, or access patterns involve lot of graph traversal, should utilize graph db. if info more tabluar, or access patterns more oriented around mass scans, should utilize rdbms. @ end of day, they're 2 different tools different niches. if utilize them in area of strength, you'll happy. if utilize rdbms model graph "because can", you'll suffer. if utilize graph database lot of mass scans of every node in every graph, you'll suffer. of tech, it's using right tool job.

sql neo4j relational-database cypher graph-databases

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -