File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes ManyToMany & fields of association table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ManyToMany & fields of association table" Watch "ManyToMany & fields of association table" New topic

ManyToMany & fields of association table

Musab Al-Rawi
Ranch Hand

Joined: Aug 06, 2007
Posts: 231
I am posting my question here since I didn't get much of response in the other forum, and it is more relevant here, sorry for repeating the question:

Here is an example to explain my questions:
let's say there is entity FOLDER that has a many to many relationship with GROUP. I could do the design as follows:

Where and How can I represent INFO?
Is the following a better design (of courseDUMMY entity won't be named DUMMY!)?
Personally I want to go for the first design but I don't know how to represent INFO field.
In that case I define Folder and Group entities as follows:
In Folder

In Group

Again how to access INFO column located in folder_group table?
Some suggested that I could use two OneToMany relationships which is possible but I am trying to figure if there is a direct solution for the situation.

Your help is greatly appreciated.

Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
A typical approach is to decompose the many-to-many relationship into two many-to-one. Then your Folder Group becomes an entity and can contain any number of additional mapped properties.
I agree. Here's the link:
subject: ManyToMany & fields of association table
It's not a secret anymore!