Re: Many-to-many w/ one entity
Re: Many-to-many w/ one entity
- Subject: Re: Many-to-many w/ one entity
- From: Clark Mueller <email@hidden>
- Date: Sun, 23 Jul 2006 21:44:19 -0500
Mark,
Thanks, that worked perfectly! That is exactly what I needed, I was
having trouble wrapping my head around how that would be put
together. :-)
Thanks,
Clark
On 23 Jul 06, at 9:04 AM, Mark Morris wrote:
Hello Clark,
You can manually model this almost the same way you would a many-to-
many involving two tables.
(Names are examples only. ;-) First create the RELATED_PRODUCT
table with just PRODUCT_ID and RELATED_PRODUCT_ID columns. Make a
to-many join from PRODUCT to RELATED_PRODUCT using PRODUCT_ID from
both tables. Then make a to-one join from RELATED_PRODUCT's
RELATED_PRODUCT_ID to PRODUCT's PRODUCT_ID. Now you can flatten
that into a "relatedProducts" relationship starting and ending at
PRODUCT. (Remove the diamond in EOModeler from the original
relationships.)
The odd thing about this is that the inverse relationship isn't
that useful. If you modeled it, it would basically be saying,
"These are the products that consider me a related product." But
it would quickly get confusing if you tried to use it! So if two
products are related to each other, just add each to the other's
"relatedProducts" relationship.
Hope this helps!
Regards,
Mark
On Jul 22, 2006, at 10:20 PM, Clark Mueller wrote:
All,
I'm trying to create a many-to-many relationship with a single
entity. Essentially, what I'm doing is trying to show "related
products" for a Product entity. EOModeler certainly won't model
this one. I have tried to model it myself (both in OpenBase
directly, and in EOModeler) mimicking the way EOModeler builds one
with two entities... but this breaks down a little bit when I try
to sort out the relationships from the intermediate table, so I
haven't had a lot of success. I am hoping that's just because I've
never done it before, and that someone can talk me through it. :-)
I've also seen this implemented in some cases by adding an
attribute (e.g. "related_products") to the entity containing data
like this:
pk_1|pk_2|pk_3
pointing to the related items. But I am sure that this is a pain
in the butt to use with EO, to actually fetch those related objects.
Can someone suggest the best way to model this relationship?
Thanks & regards,
Clark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden