-->
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.  [ 5 posts ] 
Author Message
 Post subject: Best Practice: UUID client friendly display.
PostPosted: Fri May 14, 2004 3:47 pm 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
I suppose this is an age old question, however, I thought it might be interesting to get some feedback from the Hibernate community.

With respect to UUIDs, these IDs if used as primary keys are not very useful to clients who regularly would use an ID to reference a specific record.

We've considered implementing an algorithm to create a user friendly ID at runtime which would be mapped to some DTO containing a real UUID.

Our question:

Is anyone else doing something similar? If so, how are you doing so and could you recommend any best practices based on your experience?

UUIDs are a mandatory requirement for the System.

Regards,
Roll


Top
 Profile  
 
 Post subject: RE: Best Practice: UUID client friendly display.
PostPosted: Mon May 17, 2004 9:09 am 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
Does anyone care to comment?

If we are way off the mark here, some guidance would be appreciated.

Regards,
Roll


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 9:39 am 
Beginner
Beginner

Joined: Thu Apr 29, 2004 9:36 am
Posts: 28
My inital thoughts (and I haven't thought long on this mind you) is that you're looking at a base conversion problem. Assuming that I'd solve it using a higher base. The UUID is 128 bit id (16 bytes) stored in base16 (aka. HEX). If you convert the HEX representation to Base36 or some other variant you can store more information per character.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 9:41 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
If you look at the UUID algorithm, there is also information that can be left out at the cost of "uniqueness". For example, only the two upper bytes of the IP address could be used.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 9:54 am 
Beginner
Beginner

Joined: Thu Apr 29, 2004 9:36 am
Posts: 28
My apologies, the previous post got sent before it was finished, my browser loves to send posts while I'm typing.

What I was trying to convey is the UUID is represented by 32 characters and a few dashes. Each char is representing 4bits of the 128bit id (0000-1111, 0-F, 0-15). If you're trying to make IDs that are easier to type you'll obviously want to stick within the ASCII character range. Using a ([0-9][A-Z]) range would probably be your best bet. If you used 255 characters you could map from 00000000-11111111, 00-FF, 0-255, but I doubt you want your users typing odd ASCII chars in.

Your problem is going to arise from the fact that in the English language we only have A-Z (26) and 0-9 (10) characters giving you a total of 36 possible mappings (000000-110110, 0x00-0x36, 0-36). You'd obviously like to map from 000000-111111, 0x00-0x63, 0-63) since that gives you the full 6 bit range. You could achieve this by using a case sensitive set and one "extra" char ([a-z][A-Z][0-9][*]) giving you a total of 63 options. However for all you're effort you're only going to be able to reduce the key size to 22 chars (128/6=21.33333) from the original 22.

Just some random thoughts on the topic,
Tyler


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