Recently I've started to play with cayley and ArangoDB for their graph datastores.
While reading and watching videos about graph databases a question popped up into my mind: what makes a graph database so different (and "awesome") from a typical (and horrible) EAV store in normal SQL?
In this presentation, the following citation shows up:
a graph database is any storage system that provides index-free adjacency
But what does index-free adjacency mean exactly? And how does that affect performance or design?
With the following schema, all the queries listed in the slides are possible and super simple:
CREATE TABLE "graph" (
"subject" TEXT NOT NULL,
"predicate" TEXT NOT NULL,
"object" TEXT NOT NULL
);
-- Give me all the vertex that go from "A":
SELECT "object" FROM "graph" WHERE "subject" = 'A';
-- Give me all the pairs connected by "C":
SELECT "subject", "object" FROM "graph" WHERE "predicate" = 'C';
-- Give me all the vertex that go to "B":
SELECT "subject" FROM "graph" WHERE "object" = 'B';
-- Give me all the vertex that go to "B" through "C":
SELECT "subject" FROM "graph" WHERE "object" = 'B' AND "predicate" = 'C';