By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,889 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,889 IT Pros & Developers. It's quick & easy.

Many to Many relationship between objects - The best way to implement

P: n/a
Hi everyone,

What is the best way to implement many-to-many relationship between objects?
Any examples or links are welcome!

Thank you,
Sasha
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Sasha,

The same way you would with a database, create an intermediate object that
relates the two objects.

Dan
"Sasha" <no@no.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl...
Hi everyone,

What is the best way to implement many-to-many relationship between objects? Any examples or links are welcome!

Thank you,
Sasha

Nov 20 '05 #2

P: n/a
Thank you for the answer Solex,

But who would be responsible for creating the link object, or destroying it?
I am trying to keep my model loosly coupled...
"solex" <so***@nowhere.com> wrote in message
news:ut*************@TK2MSFTNGP09.phx.gbl...
Sasha,

The same way you would with a database, create an intermediate object that
relates the two objects.

Dan
"Sasha" <no@no.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl...
Hi everyone,

What is the best way to implement many-to-many relationship between

objects?
Any examples or links are welcome!

Thank you,
Sasha


Nov 20 '05 #3

P: n/a
That is a good question. In my case I have Parties that can be related to
other parties via a PartyRelation object. I made a decision to make the
relationships directional, so that one party actually owns the relationship.

In my case it is up to the application to create the link or destory it.

Dan

"Sasha" <no@no.com> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
Thank you for the answer Solex,

But who would be responsible for creating the link object, or destroying it? I am trying to keep my model loosly coupled...
"solex" <so***@nowhere.com> wrote in message
news:ut*************@TK2MSFTNGP09.phx.gbl...
Sasha,

The same way you would with a database, create an intermediate object that relates the two objects.

Dan
"Sasha" <no@no.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl...
Hi everyone,

What is the best way to implement many-to-many relationship between

objects?
Any examples or links are welcome!

Thank you,
Sasha



Nov 20 '05 #4

P: n/a
Sasha,
In addition to Solex's suggestion.

Simply have each object own (contain) a collection of the other object. This
collection could be any .NET collection, such as: an array, ArrayList,
HashTable, or a collection derived from CollectionBase or DictionaryBase.

If you are coming from a database, then the Association Table Mapping
Pattern may be more helpful.

http://www.martinfowler.com/eaaCatal...leMapping.html

Hope this helps
Jay

"Sasha" <no@no.com> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl...
Hi everyone,

What is the best way to implement many-to-many relationship between objects? Any examples or links are welcome!

Thank you,
Sasha

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.