TypeDBT
TypeDB4mo ago
103 replies
Joshua

Modeling layered and meta graphs

Sorry to get cut off @vpavlyshyn !!

Here's a little schema that could be used:
define
  entity base-node,
    plays meta-graph-node:member;
  relation base-relation,
    plays meta-graph-mode:member;

  relation meta-graph-node,
    plays member,
    plays meta-graph-mode:member;


So now you can build your whole base-model under 'base-node' and 'base-relation' (eg, a social network):
define
  entity person,
    sub base-node,
    owns name,
    plays employment:employee;
  entity company,
    sub base-node,
    owns name,
    plays employment:employer;
  relation employment,
    relates employer,
    relates employee;


base graph:
insert
  $p isa person, has name "john";
  $c isa company, has name "typedb";
  employment ($p, $c);


Meta graph:
insert $r isa meta-graph-node;
match 
  { $x isa person, has name "John"; } or 
  { $x isa company, has name "typedb"; };
insert $r links (member: $x);
Was this page helpful?