6 Ways to Handle Relations in RavenDB and Document Databases
Daniel Lang presents 6 solutions for dealing with relations in RavenDB:
If you’re coming from the sql world, chances are you will be confused by the lack of relations in document databases. However, if you’re running RavenDB you’ve got plenty of options to address this trade-off. I personally cannot think of any situation where I’d wish back SQLServer because of this (there could be other reasons).
Two not recommended:
- go to the database twice
- include one document inside the other
Two RavenDB specific solutions:
- implement a read trigger to do server-side joins
- implement a custom responder
Two recommended solutions:
- use the
.Include<T>()method - denormalize your references
Couple of comments:
- the difference between “include one document inside the other” and “denormalize your references” is very subtle—the latter suggests including only the information needed for the presentation layer.
- I think one should consider both “include one document inside the other” and “denormalize your references” and choose one of them depending on the chances of the embedded documents being updated often vs the chances of having the presentation layer changing often
- except RavenDB, all other document databases seem to offer only two options: “go to the database twice” and “denormalize your references”
- when Redis will release its version embedding server-side Lua, that could be used as a form of stored procedure
Original title and link: 6 Ways to Handle Relations in RavenDB and Document Databases (©myNoSQL)
via: http://daniellang.net/how-to-handle-relations-in-ravendb/