1

So I'm currently trying to make a project using ravendb. And some basic moving from relational to document challenges appear.

I've been reading http://ayende.com/blog/4466/that-no-sql-thing-modeling-documents-in-a-document-database and still is. Looking at the post and categories, how would I show categories if there are no posts? I'm not making a blog, But need the user to enter some data, and some of it is an option set like categories.....which I'm in control of.

Rasmus Christensen
  • 8,321
  • 12
  • 51
  • 78

1 Answers1

2

Create a separate document used to define all categories.

The categories chosen for a post do not have to have any reference to the category definition document. They are after all just categories.

jgauffin
  • 99,844
  • 45
  • 235
  • 372
  • 1
    Well this would be what I typically would do "relational", but is this the wrong way of thinking documents? But how else would I get them? Hardcoded some where, so why not in the db. I know that after the document that should use the categories are persisted, there are no physical "relation" between the two. – Rasmus Christensen Nov 15 '11 at 21:58
  • 1
    Well looking at the sample data inside ravendb album/genre, there is a document defining genre, so after all you might be right.... – Rasmus Christensen Nov 15 '11 at 22:07
  • 1
    The difference is that you don't have a PostTags table (just a `string[] Tags` in the `Post` document. All child aggregates that do not have any external references should be inside the root aggregate (`OrderLines` are in `Order`). This post is really great: http://codeofrob.com/archive/2010/12/21/ravendb-document-design-with-collections.aspx – jgauffin Nov 16 '11 at 05:56