I have an application that tracks (for example) which drinks are available in this restaurant. My domain model looks like this:
class Restaurant {
public IEnumerable<RestaurantDrink> GetRestaurantDrinks() { ... }
}
class RestaurantDrink {
public Restaurant Restaurant { get; set; }
public Drink { get; set; }
public string DrinkVariety { get; set; }
}
class Drink {
public string Name { get; set; }
public string Manufacturer { get; set; }
}
My db scheme (I hope) about what you expect; RestaurantDrinks is essentially a comparison table between restaurants and drinks with some additional features (like DrinkVariety).
Using Fluent NHibernate to set up the mappings, I connected "HasMany" to restaurants in RestaurantDrinks, which forces the latter to be deleted when its parent restaurant is deleted.
, "Drink" , RestaurantDrinks ( ), , RestaurantDrinks, ?
: "RestaurantDrink",
References(x => x.Drink)
.Column("DrinkId")
.Cascade.All();
( FK ).