Book a Demo

Author Topic: How to implement M;N relationship between classes  (Read 2200 times)

peter king

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
How to implement M;N relationship between classes
« on: July 13, 2009, 10:31:33 am »
hi

Current i'm developing an application track storage of an item.

in it abusiness rule says an item can be moved to more than one warehouses.

Also i need to keep the history of the Item's history, Thereefore i need to create two entities,

"Warehouse" and "ItemsHistoryOfLocations". I have developped an static class diagram to show the relationshop.

These are the relationship rules between the classes:
1. A warehouse could be in an Item’s History of locations.
2. A warehouse could be in many Items’ History of locations.

therefore in the forward relationshop -- 1..*

3. In an Item's History of locations, there must be at least one warehouse
4. In an Item's history of locations, there can be more than one warehouse

Therefore in teh backward relationship -- 1..*

Therefore the relationship betwween teh classes is a M:N. In another Object oriented scripting languaage when ever,
and M:N relationship is found between classes, their relationship is slit and put a collection class called
"MemberKeyDictionaries" as the bridging entity.

But in C# / VB, should we create these collection classe. IF NOT, then how should i modify my class diagram to implement
this M:N relationship? and h0w do i implement this M;N relationship in code?


cheere