Reputation: 1200
I'm building my first small RavenDB application and I'm wondering if I'm approaching things correctly when building my domain model.
I've got a list of countries which I want to use in multiple places in my model. Typically in the past I would have created a database table to store the countries and a country object which looked a little like this:
public class Country{
public int Id {get;set;}
public string CountryName {get;set;}
}
When I went to use the country class I would have held an instance of it inside another object for example:
public class Shop{
public int Id {get;set;}
public string Name {get;set;}
public Country InCountry {get;set;}
}
Or
public class Customer{
public int Id {get;set;}
public string Surname {get;set;}
public Country CountryOfResidence {get;set;}
}
And so on and so forth. Am I correct in thinking that what I should now be doing is storing the Id of the country in the Shop
and Customer
classes so they would now look like this:
public class Shop{
public int Id {get;set;}
public string Name {get;set;}
public int CountryId {get;set;}
}
public class Customer{
public int Id {get;set;}
public string Surname {get;set;}
public int CountryOfResidenceId {get;set;}
}
When I go to pull these from the database I can then use the includes feature of the Raven API to get the related country object albeit it's in a seperate object and I can't for example do myCustomer.Country.Name
.
Obviously this is a very contrived example but I really just want to check that I'm not barking up totally the wrong tree before carrying on down this route.
Upvotes: 1
Views: 488
Reputation: 8295
I haven't properly used a document DB (yet), but my thoughts on your question are:
Upvotes: 3