Sample Header Ad - 728x90

How to maintain order when modeling outline in graph database?

2 votes
1 answer
450 views
([TaskPaper](https://www.taskpaper.com/)) outlines have a natural hierarchy relationship, so a graph database seems like a great fit. Each item in the outline is a node of the graph that points to its parent and children. I also really like the idea of modeling TaskPaper tags as nodes that any tagged items point to. However, there is one problem: the order of items is important in an outline, but a simple graph doesn't keep that information. What is the best way to maintain the order of items when an outline is stored as a graph? The method should be efficient when items are added/removed. New items may be inserted before existing items, so a simple increasing counter/timestamp won't work. The goal is to store and query a giant outline that can't fit in memory (just the necessary items are streamed to/from the user). Two common ways of querying this outline would be: - Linear: get the first n=100 items when everything is "expanded." - Breadth first, with depth first traversal of certain items: only get the top level items, fulling expanding a few selected items. (If fully expanding an item would exceed n=100 items, stop expanding.) Common updates would be: - Add/delete a new item somewhere in the hierarchy. Most inserts will probably be appending after the last child of an item. (Basic editing.) - Add/delete a new sub-tree (Copy-paste a section of an outline.) I don't think other database types would be better than a graph database, but I'm open to using other databases (relational, NoSQL, etc).
Asked by Leftium (769 rep)
Mar 2, 2020, 07:12 PM
Last activity: Nov 6, 2020, 04:11 AM