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.