graph-databasesentity-attribute-valuearangodbcayley

Difference between Graph Triples and EAV


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';

Solution

  • Index-free adjacency is a marketing buzzword.

    I agree your examples are simple and possible, but using a graph database enables you to perform queries that MySQL will not handle well. For example, if you want to know the shortest path between two vertices in a graph you can't do it using MySQL.

    In ArangoDB it is one simple call:

    GRAPH_SHORTEST_PATH("yourGraph", "StartVertex", "EndVertex")

    If you are interested in the various functions ArangoDB's graph module provides, I recommend the graph manual and the examples. I am pretty sure you will find a lot of use cases where you would struggle to achieve the same in MySQL.