473,594 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 15 '05 #1
4 2855
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******** ******@TK2MSFTN GP09.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 15 '05 #2
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******** *****@TK2MSFTNG P09.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******** ******@TK2MSFTN GP09.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 15 '05 #3
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******** ******@TK2MSFTN GP10.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******** *****@TK2MSFTNG P09.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******** ******@TK2MSFTN GP09.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 15 '05 #4
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******** ******@TK2MSFTN GP09.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 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2087
by: Mark Hargreaves | last post by:
Hopefully someone can help. I have two tables, namely master and postings: Fields include the following: master: staffno - int (11) primary key forename - varchar (20) surname - varchar (30)
3
1999
by: Mikey | last post by:
Hi all. In the process of trying to figure this thing out, I've been doing the old "stand around in the store and read as much as possible before you look like a derelict" thing. This time, with the O'Reilly "Managing and Using SQL" (I think that's it). Anyway, I was looking at a chapter discussing database design (without any direct reference to impementations in MySQL), and they mention Obj/Relationaldesign as a way to have a...
3
2806
by: Rich | last post by:
I notice that lots of the GDI+ objects implement IDisposable: SolidBrush, FontFamily, Font, etc. If I don't explicitly call Dispose() on these guys after I'm done with them, what is the downside? Is it just a longer/more frequent garbage collection, or is it worse? Personally, I allocate such temporary objects inside C#'s using statement, but not everyone does this and I'm wondering what the repurcussions could be.
6
5200
by: Anon Email | last post by:
Hi everyone, I've written some code that contains a class, and I want to track the number of instances of this class that have been created, eg.: "This is number xx object created." What is the most commonly accepted method to do this? By defining a separate "counter" class? Do I need to use a reference/ references? Cheers,
1
1674
by: ning | last post by:
It's easy to present "One - Many" relationship in XML, but how to present "Many - Many" relationship in XML?
2
2134
by: Todd D. Levy | last post by:
I have a primary table (containing basic contact information) and a number of subsidiary tables (containing various additional information) for employees. Most of the subsidiary tables have a One-to-One relationship with the primary table. There is an exception. The employees attend various events and I have a subsidiary table that tracks the Start Date and End Date of these events.
2
4709
by: Ronald S. Cook | last post by:
In my ASP.NET app, I have a few pages that I want to be public (i.e. accessible by everyone) and the rest private (user has to be signed in). In the examples I've seen, the public files have been in the root folder with it's own Web.config file and the private ones in a subfolder with a separate Web.config file. Must I necessarily use a subfolder to separate private from public files? Could I maybe have them all in the same root folder...
2
1357
by: Gav | last post by:
Hi All, I'm trying to create a table in a sql database. When I run ExecuteNonQuery(); I get an error "Objects must implement IConvertible". I put the same statement in a textbox, after getting the error I copied the
2
2216
by: The Frog | last post by:
Hello everyone, I am trying to find way of writing an SQL query that can produce missing record combinations across a many to many type setup in Access. The three tables used are as follows: Table1: Field 1
1
1707
by: johnnyD | last post by:
How would I traverse through a namespace and determine all the object types that implement an interface. For instance in the namespace "Microsoft.SqlServer.Management.Smo" Namespace I want to determine all the Classes/Types which implement the IScriptable Interface. I am not looking for anyone to code this for me, as I am trying to learn the language but any snippets or pointers would be greatly appreciated.
0
7876
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8003
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8234
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6654
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5408
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3897
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.