O'Reilly logo

RavenDB High Performance by Brian Ritchie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modeling relationships using keys

RavenDB is based on a RESTful architecture and as such supports meaningful URLs. In the preceding simple example, we have embedded the document (entity) and key into the URL. However, we can represent more complex relationships using the URL definition. For example, if we want to store each chapter with a book independently we could use the following scheme:

books/1
books/1/chapters/1
books/1/chapters/2
books/1/appendixes/1
books/1/appendixes/2

The books, chapters, and appendixes are each stored as a separate document. This allows efficient loading of a document directly by ID. Using the LoadStartingWith() method, you can also return all the chapters at once:

session.Advanced.LoadStartingWith<chapter>("books/1/chapters", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required