T
TypeDB11h ago
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;
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;
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);
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);
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);
5 Replies
Joshua
JoshuaOP11h ago
probably good to also add the relations between the base entity/relations in the base graph to the meta-graph-node also you can imagine how you can now create a layered graph by adding meta-graph-nodes into meta-graph-nodes
vpavlyshyn
vpavlyshyn10h ago
so how we handle case whan relation become and node and vs
Joshua
JoshuaOP10h ago
match
$r isa meta-graph-node;
insert $meta-meta-rel isa meta-graph-node (member: $r);
match
$r isa meta-graph-node;
insert $meta-meta-rel isa meta-graph-node (member: $r);
now the first meta graph node is a node in an even higher meta graph node
vpavlyshyn
vpavlyshyn10h ago
i love it lets write something about it one more topic - how to express ontology of db as a part of data itself and how to use typeql or db as ontology core
Joshua
JoshuaOP10h ago
what do you mean?

Did you find this page helpful?