English 中文(简体)
How to model structures such as family trees in document databases
原标题:

I have been looking into document databases, specifically RavenDb, and all the examples are clear and understandable. I just can t find any example where we do not know beforehand how many levels a given structure has. As an example how would you persist a 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 have seen we search for the aggregate root and make into a document. It is just not so obvious here what the aggregate root and boundary is.

最佳回答

I guess for RavenDb, you d have to keep the Ids 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 at the bottom, for more info: http://ravendb.net/documentation/docs-document-design

问题回答

Ayende has just posted a blog post that answers this.





相关问题
Best practices for configuring a Solr schema

I m currently configuring my schema.xml file and trying to figure out what s the best way to set up my documents. I use a RMDBS and thus many objects are relational. Take this site for instance; a ...

How to register for callbacks on a DB4O server?

I have a DB4O server listening on a port IObjectServer server = Db4oClientServer.OpenServer("filename.db40", 11978); How do i register for callbacks? For example how do i execute some custom ...

Are there any small scale, durable document/object databases?

I have a few .Net projects that would benefit from using a document/object database opposed to a relational one. I think that db4o would be a good choice, but we re not sure how much the cost is. I ...

热门标签