• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Properties of Many-To-Many relationship

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need some help setting up relationship properties in EJB3.0. To be more specific consider the following example.

Let us presume I have an entity ExpenseType which holds all kinds of expense types for some expense charge. One of those expense types could be 'Ethernet cable'. An organization could have different price for this ethernet cable when being sold to education institutions in comparison to price when being sold to military.
So we have ExpenseRateCategory entity with two entries (Education and Military) and ExpenseType entity with one entry (Ethernet cable). These have Many-To-Many relationship. I have created entities ExpenseType and ExpenseRateCategory and have managed to establish the relationship between them. The record of the join table holds FKs to ExpenseType.ID and ExpenseRateCategory.ID.

ExpenseRateCategory.ID | ExpenseType.ID

The problem is how to add additional fields to this relationship, namely the price, the value of which depends on both sides of the relationship. That is I want to have record of the join table of the form:

ExpenseRateCategory.ID | ExpenseType.ID | price

How to manipulate those additional fields in the context of EJB3 specification?
[ October 18, 2005: Message edited by: Jurica Ursic ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jurica,

I was wondering if you solved this one. I'm trying to do something very similar, and while I am close to the full solution, I am apparently missing something.

Thanks...

-mark
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wouldn't you normally create a join table and use that as the link between the many to many?

Mark
 
Mark James
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's the fact that it's not a junction table, it's an association table - i.e. it has additional business info (fields), including one that is part of the composite pk. (i.e. it's "transactional" and not "transparent")

So (in my case), you have 2 fk's, both of which are part of the primary key, along with one of the "extra" fields. Now, since pk's are unique, don't you end up with two on-to-one relationships due to the unique constraint being applied to the fk's? Is that what you want out of a "many to many, plus data" relationship?

Thx!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic