UUID

Hello Friends, Is there any better alternative for UUID? Can you please provide me a link.

Thanks Abhis

Alternative to what? If you need ideas, take a look at how Authlogic generates them in the Authlogic::Random module.

Darian Shimy

Hello Darian, Thanks for your reply, Basically for generating Primary Key which is not just an auto increment.

thanks abhis

I would like to extend this discussion somewhat as I don't see any guarantee that the id generated by "the authlogic method" will in fact meet the requirement placed on that generated by uuid.

The UUID (Universally Unique IDentifier) has it's primary requirement spelled out in the name. The provided id is meant to be unique across multiple platforms without requiring any interplatform syncronization.

At it's base, authlogic provides an identifier (session key) which is a random number. The random number source has evolved over time with the current (inside RoR) technique provided in Ruby 1.9 being SecureRandom. Rails 2.3.4 also provides ActiveSupport::SecureRandom which provides equivalent functionality and defaults to Ruby1.9 if present.

SecureRandom will use, preferentially:   ossl library random_bytes()   /dev/urandom   Window's CryptGenRandom

My problem is that I cannot find any guarantee that SecureRandom will provide a value that meets the UUID requirement. Can anyone see what I'm missing here?

Hi Abhishek

You could override the rails defaults of autoincrementing with following

create_table(table_name,:id => false) do |t| t.integer :id,:options => ‘PRIMARY KEY’ end

 Force fully in your controller you should pass the value to :id .

Hope this helps ,

Srinivas Iyer
[http://talkonsomething.com](http://talkonsomething.com)

Hey Rick, Yes Even I am looking out for some different solution for storing unique ID as a primary key instead of UUID as it stored a 36 character string.

You can find more detail on http://www.mysqlperformanceblog.com/2007/03/13/to-uuid-or-not-to-uuid/

Thanks Abhishek Shukla