aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to store normalized OneToMany records with Java EE 5 (GF2.1 & MySQL) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to store normalized OneToMany records with Java EE 5 (GF2.1 & MySQL)" Watch "How to store normalized OneToMany records with Java EE 5 (GF2.1 & MySQL)" New topic
Author

How to store normalized OneToMany records with Java EE 5 (GF2.1 & MySQL)

Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi All,

I would like to find out how to store only a single record in a OneToMany table mapping relationship. Below is an example of what I am try to achieve:

Family (OneToMany) Telephone (ManyToOne)
------------------------------ -----------------------------------
John Smith (father) 1234-5678 (phone line)
Joyce Smith (mother) 1234-5678 (phone line)
Holy Smith (daughter) 1234-5678 (phone line)
Christopher (son) 1234-5678 (phone line)

Currently, the Telephone table is filled up with the same record 4 times which makes it harder to maintain and slow down searches over time, not to mentioned the unnecessary redundant inserts.

I am wondering whether it is possible to maintain a single Telephone record reference by the whole family. This proposition seems to inclined to the ManytoOne relationship even though it can also be a ManyToMany.

My Java EE 5 (JDK1.6.017, Glassfish 2.1) JMS Session Bean application is persisting the records correctly but grinds to a halt after having processed a 600,000 thousand records on the Telephone tables in MySQL (Windows XP). The record ratio between Family and Telephone tables are 1:50.

Any suggestion on improving this model in an effort to streamline the database and speed would be much appreciated.

Thanks,

Jack
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to store normalized OneToMany records with Java EE 5 (GF2.1 & MySQL)