Fork me on GitHub
#datalog
<
2020-08-12
>
lgessler01:08:36

hi, i need to model labeled edges and i'm wondering about the best way to do it in a db like datomic or crux. I have relations like this, using cypher: (a:A)-[r:REL {foo: "bar", ...}]->(b:B). the off-the-shelf way to do this is to make the relation a separate entity and join to a and b on r , like {:r/id :my-id, r/a-join :id-for-a, :r/b-join :id-for-b, :edge-attr1 ..., :edge-attr2 ...} but I want to instead model it by having a have a join to r and have r have a join to b: this helps me structurally represent the directionality of this edge. hope that makes sense--can anyone comment on whether it'd be OK to pursue the latter model, and whether there are any others i ought to consider?

lgessler01:08:36

hi, i need to model labeled edges and i'm wondering about the best way to do it in a db like datomic or crux. I have relations like this, using cypher: (a:A)-[r:REL {foo: "bar", ...}]->(b:B). the off-the-shelf way to do this is to make the relation a separate entity and join to a and b on r , like {:r/id :my-id, r/a-join :id-for-a, :r/b-join :id-for-b, :edge-attr1 ..., :edge-attr2 ...} but I want to instead model it by having a have a join to r and have r have a join to b: this helps me structurally represent the directionality of this edge. hope that makes sense--can anyone comment on whether it'd be OK to pursue the latter model, and whether there are any others i ought to consider?

quoll01:08:47

Are you saying that you want to have a unique label for every edge?

lgessler01:08:54

sorry, should have made that clearer: i mean i need every edge to be an entity because i want to label each edge with various attributes

lgessler01:08:03

updated my example above

quoll01:08:02

Yeah, I think for something like Datomic you’ll need to model with an entity per edge

rob70311:08:27

I have the exact same challenge right now, and came to the same conclusion this morning. I think we need an entity per edge, or a general entity like

:in  :ref
:out :ref
:additional-stuff ...

rob70311:08:05

But I'm not 100% sure yet, since it's my first project with datomic