-->
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: [Resolved] Should I go with natural key since I have UUID
PostPosted: Wed Apr 25, 2007 11:02 am 
Newbie

Joined: Thu Feb 08, 2007 7:12 am
Posts: 3
My colleagues and I are working on a simple application, basically we process a Sunbird iCal file(published via http) and save it to the databse. All what is relevant are the Events. We have a simple POJO

Event

Code:
Long id=...;
String uid =...; // from iCal, this is pretty much UUID
String forUser=...;
Date fromDate=...
Date toDate=...
String summary=...


Now I am a bit puzzled, is having two IDs the way to go? Is it better to have a synthetic key anyway, since uid's are huge strings up to 255 chars. Will there be a significant difference between having a synthetic number as a key or a long string as a natural key? I am not that good with databases yet, so any comments you have are very welcome. What do you recommend? Should I get rid of id and just use uid instead?

Having a uid as a key would simplify processing when a calendar is republished while one could change an event in his/her calendar that is already in the database but the uids would be the same. That means we could just do a saveOrUpdate for all the events and we could be sure that we will not have duplicated. But that implies we will do as much Update calls as there are old events? The alternative is to find all the events for the user and then see from the uids if the event needs updating or not(in that case natural key will not be needed) that would be most probably result in less Update calls? Same number of Inserts ofcorse.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 9:57 am 
Newbie

Joined: Thu Feb 08, 2007 7:12 am
Posts: 3
Silly me, I think I should stay away from natural keys but using so called unique keys is an ok idea? So in my case I will just put uniqe="true" on uid property and thats it.


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.