• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help on mapping

 
Charu Sama
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was looking into simple many-to-many mapping for two entities user and group, which involved 3 tables i.e. table USER, table GROUP and table USER_GROUP. so, my question is - do we really need table USER_GROUP for this mapping. Is there other way to do the many-to-many mapping just with 2 tables USER and GROUP (without USER_GROUP).
What is the significance of having USER_GROUP table?

Please provide your input.

Thanks in advance.
 
Xavier George
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too have similar problem and posted on hibernate forum.

Below is the post.
----------------------------------------

Can we have <many-to-many> mapping without the link table.

Excerpt from tutorial


If you wish to represent a many-to-many association in a relational database, you must introduce a new table, called a link table. This table doesn�t appear anywhere in the object model. For our example, if we consider the relationship between a user and the user�s billing information to be many-to-many, the link table is defined as follows:

CREATE TABLE USER_BILLING_DETAILS (
USER_ID BIGINT FOREIGN KEY REFERENCES USER,
BILLING_DETAILS_ID BIGINT FOREIGN KEY REFERENCES BILLING_DETAILS
PRIMARY KEY (USER_ID, BILLING_DETAILS_ID)
)
 
Charu Sama
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please share your thoughts on this.

Thanks in advance.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!