-->
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.  [ 3 posts ] 
Author Message
 Post subject: Simple data modeling question, related to Hibernate
PostPosted: Thu Feb 23, 2006 6:26 pm 
Newbie

Joined: Thu Feb 23, 2006 5:55 pm
Posts: 2
Hi,

I am pretty new to Hibernate, I have a very simple data modeling question ---

We have a composite key, it is the key for 10 of our total 30 tables, there is 2 way to design this,

a) put this composite key in each of 10 tables
b) put this composite key in a seperate table with a unique_id, and use this unique_id as key in the 10 tables

for a)
--------------------
Profile_table
--------------------
User_id (key1)
Site_id (key2)
profile_data
...
...
----------------------
and same for each of 10 tables



for b)
--------------------
User_table
--------------------
User_id
User_Master_id (key1)
Site_id (key2)
...
---------------------
---------------------
Profile_table
---------------------
User_id
profile-data
...
...
----------------------

Then use User_id in other tables



For a) I dont like it, because data redundency
For b) every time I retrieve data from a table like - Profile, I have to join the User-table,

so, the question is how difficult to do the join relationship in Hibernate? Could this join be generate automatically if I use hql. The problem is if I dont use Hibernate, there is no doubt for me to use (b), but by using hibernate, somebody argued the data better be in one table.

Any input are welcome, thank you very much.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 6:48 am 
Beginner
Beginner

Joined: Wed Aug 04, 2004 4:33 am
Posts: 45
Location: Switzerland
I would use the approach b) . This is a usual mapping, I can't see why this should be a problem with hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 5:32 pm 
Newbie

Joined: Thu Feb 23, 2006 5:55 pm
Posts: 2
this is what they argued about (b)
--------------------------------------------
As long as we use hibernate, if the query is done in one table, we can use
entity manager.
If the site_id information is in separate table, whenever we need to get
data in particular site, we need to join the table that contains site_id
information. In that case, we cannot use entity manager because the query is not simple operation for one table.


less join would become simple because entity manager can
handle operations for one table.

Moreover, usually CRUD application's reference request must be paginated. So
that, one table entity contains all the required attribute for the operation
achive simple access because without having inner query or joining, simple query can achieve all the request.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.