Thanks for checking it out. In this case I want to use UUIDs because
relational databases are only one of the possible storage strategies and
because I want to be able to move some data around (production <-> local).
And yes, at least one of the storage strategies can do sharding.
One other thing I needed to make everything work in my case was foreign_key
in the migration.

# I used this
char :site_id, :size => 36, :null => true, :key => :id, :table => :sites

# Instead of this
foreign_key :site_id, :table => :sites

Thanks again for the info.

Sincerely,


Adrian Madrid
My eBiz, Developer
3082 W. Maple Loop Dr
Lehi, UT 84043
801-341-3824


On Thu, Sep 24, 2009 at 14:19, Jeremy Evans <[email protected]> wrote:

>
> On Sep 24, 10:13 am, Adrian Madrid <[email protected]> wrote:
> > I'm interested in using UUIDs instead of integer for primary keys in some
> of
> > my models and I'm not sure what would be the best way to implement it in
> > Sequel. I'm thinking something like this:
>
> The best practice would be to use integer keys instead of UUIDs, IMO.
> UUIDs primary keys are only helpful in fairly limited circumstances
> (e.g. partitioned databases), so unless you really need them, I'd
> avoid using them.
>
> > class ExampleMigration < Sequel::Migration
> >
> >   def up
> >     create_table(:examples) do
> >       String   :id, :size => 36, :unique => true
> >       String   :name
> >       DateTime :created_at
> >       DateTime :updated_at
> >     end
> >   end
> >
> >   def down
> >     drop_table :examples
> >   end
> >
> > end
> >
> > class Example < Sequel::Model
> >
> >   def before_create
> >     super
> >     self[:id] = CustomUUID.generate
> >   end
> >
> > end
> >
> > What would you do differently and why? Is there any possible problems
> with
> > this type of primary key? Any comments would be appreciated but please be
> > gentle ;-)
>
> Your implementation is probably the best way to implement them.  There
> isn't real problem using them (Sequel should work with UUID primary
> keys just fine), other than the performance impact of using 36
> character strings over simple integers.  I just don't see any
> advantages unless you are using a partitioned database.
>
> Jeremy
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to