c# - "Clue" like relational database design: Schema must enforce entity multiplicity across related entities. -


i have business case requires as possible implement database schema application prevents incorrect state entity called trailers in more 1 location entity, called bays or lots.

the code snippets relevant parts of entity models below.

essentially, problem cannot figure out how create schema prevent trailer being in lot, , in bay @ same time, while keeping 1 many relationship lots trailers , 1 1 bays trailers.

i can things mitigate problem in application, having schema prevents state better.

anyone have thoughts on how might best accomplished?

 public class trailer {      public int trailerid { get; set; }     public maintstatuses maintstatus { get; set; } .... }  public class location { [key]     public string locationname { get; set; }     //navigation     public virtual icollection<bay> locationbays { get; set; }     public virtual lot parkinglot { get; set; } ... }  public class bay {     [key]     public int id { get; set; }     public string bayname { get; set; }     //navigation     public virtual trailer trailer { get; set; }     public virtual location location { get; set; } ... }  public class lot {     [key]     public string lotname { get; set; }     [foreignkey("location")]     public string locationname { get; set; }     public virtual location location { get; set; }    public virtual icollection<trailer> parkedtrailers{get; set;}  ... } 


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -