-->
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.  [ 1 post ] 
Author Message
 Post subject: Denormalization in an Object Model?
PostPosted: Sat Dec 06, 2003 9:41 am 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
The fact I am considering this probably means my object model sucks, but hey.

My idea was to have declarations in the database and hibernate enforce integrity for me. I'm not sure sure that's 100% possible.

Here's the problem.

I have a User object that has multiple UserData objects associated with it (each one has userdata specific to a given language). There originally was a Set of Userdata inside of User

So for Hibernate, I implemented a LanguageCode object and declared UserData Many-to-One to both the User and LanguageCode objects.

At the time I wondered if this was the right way to go. I mean LanguageCode basically only contains a String. The only reason I created it at all was for declaring the Many-to-one relationship that existed, thinking Hibernate would help enforce it.

Simple so far, right?

Eventually I came to the conclusion that in order to easily get to a specific language's UserData Object, I should make UserData a Map element of User. Again no problem.

But Referencing the Map with a LanguageCode Object is cumbersome. I should be able to reference it with the approriate String. (Be aware that I have other tables where this problem would appear. This is just one such example)

My options appear to be:

1) Punt the LanguageCode many-to-one entirely and just make it a string instead, relying on a FK in the database to enforce it for me

2) Keep it, and create a string field in the class too which I can reference for purposes of the map. I keep my many-to-one, but if I do this "denormalization" though, what did I gain??? I mean, why bother?

Suggestions?

_________________
"A statistician is a mathmetician, broken down by age and sex".


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.