datalog

lgessler 2020-08-12T01:16:36.113900Z

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?

xceno 2020-08-17T11:14:27.125900Z

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 ...

xceno 2020-08-17T11:15:05.126100Z

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

quoll 2020-08-12T01:28:47.115600Z

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

quoll 2020-08-12T01:40:22.116800Z

I do it differently, but you might get some success using this technique: https://gist.github.com/taylorSando/36e7f6593e503a38bb10

lgessler 2020-08-12T01:46:54.117Z

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

lgessler 2020-08-12T01:48:03.117400Z

updated my example above

quoll 2020-08-12T01:50:02.118900Z

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