Search code examples
neo4jarangodb

Is there a graph database which allows for arbitrary edge types to be added without requiring a wholesale migration?


Here's the use case: say I wanted to build a notes app that allows users to cross-link between notes, or parts of notes. When the user creates a cross link (edge), they can specify the type of link (edge type). The user can also enter a custom link (edge) type.

For example, a user writes one note about Celia and another about Barry. She then links the Barry note from Celia, with a link type "HUSBAND". She links the Celia note from Barry, with a link type "WIFE". Neither "WIFE" nor "HUSBAND" were explicit edge types in the pre-existing schema of the graph database.

In most graph databases I've looked at (e.g. Neo4j, ArangoDB, Amazon Neptune) adding a new 'type' of edge (link) between nodes requires a wholesale migration of the database, since edges are typically stored as collections in those systems.

Rather than allowing the user to define new collections on the fly, are there any graph databases which treat edges differently, i.e. don't require me to define all possible edge types up front?


Solution

  • What you are describing here sounds similar to how you might think about modelling a hypergraph. If it is important to have, using your example of HUSBAND and WIFE declared before Barry and Celia, then you may well consider modelling HUSBAND and WIFE as nodes in their own right, and then when data of Barry and Celia are entered into the database, you would attach them to those nodes. How you might model this will vary, but an example (of many) may be (Wife)<-[:HAS_REL_TYPE]-(Celia)-[:KNOWS]->(Barry)-[:HAS_REL_TYPE]->(Husband)