1

I'm trying learn more about RavenDB and at the moment to focus on how to write good Indexes for RavenDB.

Let's say I have a object, Session, with an organization as a property and I want to group all sessions by the organization. And also I wan't the result to contain a list with all Sessions. How can I accomplish this?

public class Session {
    public string Organization { get; set; }
    ...
}

public class OrganizationSessions {
    public string OrganizationName { get; set; }
    public List<Session> Sessions { get; set; }
}

Any help is appreciated!

Seb Nilsson
  • 26,200
  • 30
  • 103
  • 130
Nordis
  • 733
  • 2
  • 9
  • 31

1 Answers1

2

Not the right question to ask.

Ask yourself what are you trying to do, and what model entities make the most sense to have. Then move from there.

Don't assume a class structure like you would have for a relational model.

synhershko
  • 4,472
  • 1
  • 30
  • 37
  • Well I'm not assuming a class structure based on a relational model. All Session objects I store have no other references. The Organization property is just a string. I thought this is what a map reduce index is about, to group on a property..? If I'm totally wrong please feel free to give me a hint in the right direction. – Nordis Jun 25 '12 at 07:37
  • So just save the OrganizationSessions object as is. Unless it is expected to be large, this is the way to go. – synhershko Jun 25 '12 at 17:24
  • Session is our primary object and this is almost the only object we use. Session has no relationships at all. The property "organization" is only a string. What I'm trying to accomplish is to group by organization to render a view in our application to show some statistics. – Nordis Jun 27 '12 at 11:48
  • I appreciate you taking the time to answer my question! :) I know I can solve this "problem" in other ways. But I'm still wondering if it's possible to do as I described in my question? – Nordis Jun 27 '12 at 11:58