A modeling question for RavenDB (or other doc-oriented databases)

It is amazing how some of the more experienced (or those with a better idea than mine) will solve my specific simulation scenario ...

I have a typical script Category → SubCategory → TertiarySubCategory and I'm not sure if I am matching it correctly. I correlate this directly with the MVC route, since the raven seems to do a good job of this. In the last category (which may be at the first, second or third level there will be a list of elements related only to this level of the category. Thus, we may have something like:

Category of one level: '/ Politics /'

Second level category: "Politics / People" or "Politics / Websites"

Three-level category: "Sports / Pro / Volleyball" or "Sports / College / Football"

In a traditional RDBMS, this is easy through primary / foreign keys + several associations ... so, I wonder how I will deal with Raven?

From what I read, should I store the entire "URI" or "Key" in sports / pro / volleyball in the list of items that fall under it?

i.e. -

public class CategoryItem
{
     public string FriendlyName {get;set;} // Volleyball or Pro Volleyball
     public string CategoryURI {get;set;}  // i.e. - "/sports/pro/volleyball/"
     public string content {get;set;}  // i.e. - "Who is the best Pro Volleyball Athlete?"
     public List<string> Comments {get;set;}
}

// then we could store something like this:

var survey1 = new CategoryItem();
survey1.CategoryURI = "/sports/pro/volleyball/"
survey1.Content = "Who is the best female pro volleyball player?";
survey1.Comments.Add(new Comment("Misty May"));

var survey2 = new CategoryItem();
survey2.CategoryURI = "/sports/pro/volleyball/";
survey2.Content = "Who is the best male pro volleyball player?";
survey2.Comments.Add(new Comment("Some guy I don't kow");

// asuumes ravenSession was alreadyopened... 
ravenSession.Store(survey1);
ravenSession.Store(survey2);
ravenSessoin.SaveChanges();


//{ ...... etc .....  }
//Then I can query by CategoryURI without needing joins (denormalization)....  i.e. - 

var items = session.Query<CategoryItem>()
                 .Where(x => x.CategoryURI == "/sports/pro/volleyball/");

Or do I need to create an item list item from an actual category class? Each element has a list of its own comments ... which means everything that is stored in one document inside Raven - i.e. -

public class Category
{
    public string FriendlyName {get;set;} // i.e. - "Volleyball" or "Pro Volleyball"
    public string URI {get;set;}  // i.e. -  "/sports/pro/volleyball"  which is the MVC path
    public List<CategoryItem> Items {get;set;}
}

public class CategoryItem
{
     public string Content {get;set;}
     public List<string> Comments {get;set;}
}

var vballCat = new Category();
vballCat.FriendlyName = "Pro Volleyball";
vballCat.URI = "/sports/pro/volleyball/";  // equivalent to the MVC route

var catItem = new CategoryItem().
catItem.Content = "Who is the best male pro volleyball player?";
catItem.Comments.Add("Misty May");
catItem.Comments.Add("Some Guy 1");
vballCat.Items.Add(catItem);

ravenSession.Store(vballCat);
ravenSession.SaveChanges();

..... now that I am pulling out the main cat, that is - "/ sports / pro / volleyball /" I have everything I need already under it "

var items = session.Query<Category>()
                 .Where(x => x.URI == "/sports/pro/volleyball/");

{............. etc................}

Items .... ? , ? , !?!?

, . , / ... , . !

+3
1

, . , . , , ( , - , ). , RavenDB , / , , . , .

, , - , , , . , , , .

+2

All Articles