How to model structures such as family trees in document databases

I studied document databases, in particular RavenDb, and all the examples are clear and understandable. I just can’t find a single example when we don’t know in advance how many levels a given structure has. As an example, how would you save the family tree, given the following class:

public class Person{ public string Name {get;set;} public Person Parent {get;set;} public Person[] Children {get;set;} } 

In most examples, I saw how we look for a composite root and insert it into a document. Here, it is simply not so obvious what the aggregate root and boundary are.

+4
source share
2 answers

I believe that for RavenDb you need to store the identifiers in your object:

 public class Person { public string Name { get; set; } public string ParentId { get; set; } public string[] ChildrenIds { get; set; } } 

Check this page, especially below, for more information: http://ravendb.net/documentation/docs-document-design

+2
source

Ayende just posted a blog post that responds to this.

+3
source

Source: https://habr.com/ru/post/1313326/


All Articles