-->
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: Combined surrogate and natural strategy!?
PostPosted: Thu Feb 23, 2006 8:19 pm 
Newbie

Joined: Fri Oct 01, 2004 1:29 pm
Posts: 5
Location: Brasil
Hi!

Surrogate or natural keys is old discussion, but what about combined surrogate and natural strategy?

My intention is to simplify PK mapping to Hibernate mapping tool and cut-off java equals/hashCode methods implementation and so on....
according to Hibernate FAQ's, wiki, this forum..I read all these!

But I want to still be able to do maintenance on data in the database using pure and "simple" sql...

Creating simple FK to PK in the surrogate strategy will result in simple joins, but complex sql for data manipulation (to me, not Hibernate)

But, if I have PK's in surrogate style + natural keys in the form of a UNIQUE KEY, then in the sub-entities the integriy references the natural UK, not the surrogate PK, I cold agregate all advantages of these 2 strategies!

So I'm wondering if this is good pratice, but in the net, not much about this :(

Code:
---------------
|  Entity A   |
---------------
|             |
| # id   (pk) |
| # numA (uk) |            ---------------
| # desc      |            |  Entity C   |
|   date      |            ---------------
---------------            |             |
                           | # id (pk)   |
---------------            | # numA (fk to A->numA)  | numA + numB combined to UK (Natural Key)
|  Entity B   |            | # numB (fk to B->numB)  | no one reference do A->id or B->id
---------------            | # text      |
|             |            |   date      |
| # id   (pk) |            |   etc       |
| # numB (uk) |            ---------------
| # desc      |
|   date      |
---------------


What you find? What is the impact for hibernate mapping?


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