We want to use a graph database to store the data model of documents, in our system. The data model for each document is be a single rooted tree. So in our graph database there would be hundreds of millions of single-rooted trees, one per document.
Each tree can be of arbitrary depth and arbitrary shape, though it is always a tree. Typically a document tree would consist of thousands of nodes. The nodes in the tree for a document have a document ID property, whose value is the ID of the document. The document ID is a UUID.
Occasionally and purposefully, a branch of the tree for a document is orphaned from the main tree for that document. This happens when content is deleted. At the time content is deleted, the branch corresponding to that content is simply un-parented from the tree. We do this for good reason, which I won’t go into. i.e. We cannot delete the branch at that point.
At a later time we want to garbage collect and remove these orphaned branches from the database. Essentially we want to query for nodes whose document ID is x, and that do not have a parent. And then delete that node and its descendants. i.e. Delete the orphaned branches for document with ID x.
Is that kind of query possible with Dgraph? Can it be done efficiently?
Thanks,
Michael-