You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our current system, node A may only point at node B if
node B is not a subdocument, or
node B is a subdocument of A (including things like list/array cells and json objects)
This enforces ownership semantics. Because everything in a terminusdb graph is either a document, or (transitively) owned by a document, we can safely perform deletions of subdocuments when the containing document is deleted, knowing for sure that nothing else is still pointing at the deleted data.
But sometimes, we want to point at data that is not ours. A case where this recently came up was in thinking about indexing structures. Assume for example that you have a linked list of words, and you want to keep track of each unique word and where in the linked list this word is stored. A natural approach would be to have a 'Word' document for each unique word, which links to the cells of this linked list where this word is used. But we cannot do that, because the 'Word' document does not own that cell.
As a solution I propose that we introduce weak links. With weak links, a type is able to declare that one of its fields is a subdocument which it doesn't own. Since it doesn't own it, we need to take into account that it may disappear. Therefore, a weak link should behave in practice like either an Optional or a Set. That way, when the node pointed at is deleted, the weak link can also safely be removed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In our current system, node A may only point at node B if
This enforces ownership semantics. Because everything in a terminusdb graph is either a document, or (transitively) owned by a document, we can safely perform deletions of subdocuments when the containing document is deleted, knowing for sure that nothing else is still pointing at the deleted data.
But sometimes, we want to point at data that is not ours. A case where this recently came up was in thinking about indexing structures. Assume for example that you have a linked list of words, and you want to keep track of each unique word and where in the linked list this word is stored. A natural approach would be to have a 'Word' document for each unique word, which links to the cells of this linked list where this word is used. But we cannot do that, because the 'Word' document does not own that cell.
As a solution I propose that we introduce weak links. With weak links, a type is able to declare that one of its fields is a subdocument which it doesn't own. Since it doesn't own it, we need to take into account that it may disappear. Therefore, a weak link should behave in practice like either an Optional or a Set. That way, when the node pointed at is deleted, the weak link can also safely be removed.
Proposals for schema notation:
Beta Was this translation helpful? Give feedback.
All reactions