-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: many to many relations between objects of the same class
PostPosted: Thu Jul 15, 2004 2:59 pm 
Newbie

Joined: Thu Jul 15, 2004 1:07 pm
Posts: 9
I have a design/best practice question.

My app that uses a entity table with a many to many relationship to itself. For example, my entity table is for a 'Word' object. A synonym relationship table relates a word to another word.

I have successfully implemented a many-to-many relationship using a set, but it only works one way. If my relationship table has the columns, word_id and synonym_word_id, and word A is the word_id and instance B is the synonym_word_id, when the two objects are queried from the database, B is listed as a synonym for A, but the reverse does not happen (and I wouldn't expect it to).

What is the best way to handle this pattern?

I was hoping NOT to double enter every relationship (entering A/B and B/A) in the synonym table.

I am not sure it's necessary for synonyms be stored in a set. One alternative would be to just execute a query when synonyms needs to be listed. Currently I don't have a class representing the synonyms table, so I'm not sure how to query against that relationship table (or do inserts/updates/deletes).

Thoughts?

Thanks,
Jay


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 16, 2004 1:28 am 
Newbie

Joined: Tue Jul 13, 2004 12:35 am
Posts: 2
Location: Berkeley, CA, USA
If you have a many-to-many relation from Word to itself, then Word can have two properties, say forwardSynonyms and reverseSynonyms. For the set of synonyms, combine the two sets from these properties.

_________________
Mike


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.