TypeDBT
TypeDB5mo ago
42 replies
georgii

Storing and retrieving lists of entities

Moving from: https://discord.com/channels/665254494820368395/699946888572567611/1413211154020565002
From @nphair @kevinsullivan

Hi all, is there a general strategy you recommend for converting from inductive data types to typedb's ER model?

The simplest example that I suspect has come up before is a List. Assuming a typical definition (this is Lean)
inductive List (α : Type u) where
  | nil : List α
  | cons (head : α) (tail : List α) : List α


Then i am trying to model data of this form for a small set of types with
ListValueEntity sub entity;
ListValueEntityToElementRel sub relation;
ListValueEntityToElementRel owns ListValueIndexAttr;
ListValueEntityToElementRel relates ListValueEntityToElementRelListRole;
ListValueEntityToElementRel relates ListValueEntityToElementRelElementRole;

ListValueEntity plays ListValueEntityToElementRel:ListValueEntityToElementRelListRole;
ListValueEntity plays ListValueEntityToElementRel:ListValueEntityToElementRelElementRole;
NatValueEntity plays ListValueEntityToElementRel:ListValueEntityToElementRelElementRole;
BoolValueEntity plays ListValueEntityToElementRel:ListValueEntityToElementRelElementRole;
StrValueEntity plays ListValueEntityToElementRel:ListValueEntityToElementRelElementRole;
...


Does that seem reasonable? I am able to write data of this form, but am having a hard time preserving the structure of things like Lists of Lists on fetches.
Was this page helpful?