:) I'm not quite sure, actually. I need to be able to store different kind of trees.
And one of these kinds can potentially contain a lot of levels. In one way it's very similar to a file system. I've got folders with sub-folders and content (not being folders), kind of. I've looked into storing everything in one document. But that won't quite be the right thing. I have to be able to load a sub-part of the tree. The tree will potentially be too large to load everything at once, so I would like to be able to lazy-load sub-folders.
I've also looked into storing the entire parent-path in each folder-document. Storing both the parent_id and generating the parent-path on updates would maybe do what I want? But this solution, as well as the Modified Preorder Tree Traversal, will require a lot of processing when changing the folder structure.
I've also considered another approach; I wouldn't mind if moving a folder around in the structure "locks" the entire structure when updating, but I would like to be able to change the name of the folder without this happening. To accomplish this I have wondered if it would be a solution to keep one document for organizing the folder-structure, but keeping all of the data (folder name, the folders content items etc) in another document. Would look something like this:
folderstructure/1
{
"Package": "Resource collection 1",
"Folders": [
{
"ThisFolder": "folder/1",
"Children": [
{
"ThisFolder": "folder/2",
"Children": []
}
]
}
]
}
folder/1
{
"Name":"Documentation",
"Content": [
"content/2",
"content/19"
]
}
This would also allow me to place a folder in multiple folder structures. This would in a way solve my problem, but would this be a stupid way of using a document-database? Given the extensive usage of document-links ...
What do you think?