[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Sequel primary keys

Glen Holcomb

6/24/2008 4:02:00 PM

[Note: parts of this message were removed to make it a legal post.]

I posted to the Sequel Google Group but it's horribly slow, assuming it took
my post.

Does anyone on here know if it is possible to create a non-integer primary
key in Sequel? If so how? Also help with creating a non integer foreign
key would be great too. I've done some poking through the Rdoc and some
experimentation and it wants to make everything :integer or AUTOINCREMENT.

Thanks,
Glen

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

15 Answers

Robert Klemme

6/24/2008 5:01:00 PM

0

On 24.06.2008 18:01, Glen Holcomb wrote:
> I posted to the Sequel Google Group but it's horribly slow, assuming it took
> my post.
>
> Does anyone on here know if it is possible to create a non-integer primary
> key in Sequel? If so how? Also help with creating a non integer foreign
> key would be great too. I've done some poking through the Rdoc and some
> experimentation and it wants to make everything :integer or AUTOINCREMENT.

The docs seem to indicate that you can use arbitrary PK's:

http://sequel.rubyforge.org/classes/Sequel/Schema/Generator.ht...

So, if int is enforced there is a bug - either in your code or in
Sequel's code.

Kind regards

robert

Glen Holcomb

6/24/2008 6:14:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Tue, Jun 24, 2008 at 11:03 AM, Robert Klemme <shortcutter@googlemail.com>
wrote:

> On 24.06.2008 18:01, Glen Holcomb wrote:
>
>> I posted to the Sequel Google Group but it's horribly slow, assuming it
>> took
>> my post.
>>
>> Does anyone on here know if it is possible to create a non-integer primary
>> key in Sequel? If so how? Also help with creating a non integer foreign
>> key would be great too. I've done some poking through the Rdoc and some
>> experimentation and it wants to make everything :integer or AUTOINCREMENT.
>>
>
> The docs seem to indicate that you can use arbitrary PK's:
>
> http://sequel.rubyforge.org/classes/Sequel/Schema/Generator.ht...
>
> So, if int is enforced there is a bug - either in your code or in Sequel's
> code.
>
> Kind regards
>
> robert
>
>
Thanks for the input Robert.

It turns out there is a rather vaguely documented :auto_increment => false
that needed to be included in my primary_key definition. Now I just need to
figure out how to get foreign_keys to work. The sequel-talk group seems to
be working so I will continue this pursuit there.

Thanks again.

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

Todd Benson

6/24/2008 6:52:00 PM

0

On Tue, Jun 24, 2008 at 1:13 PM, Glen Holcomb <damnbigman@gmail.com> wrote:
> On Tue, Jun 24, 2008 at 11:03 AM, Robert Klemme <shortcutter@googlemail.com>
> wrote:
>
>> On 24.06.2008 18:01, Glen Holcomb wrote:
>>
>>> I posted to the Sequel Google Group but it's horribly slow, assuming it
>>> took
>>> my post.
>>>
>>> Does anyone on here know if it is possible to create a non-integer primary
>>> key in Sequel? If so how? Also help with creating a non integer foreign
>>> key would be great too. I've done some poking through the Rdoc and some
>>> experimentation and it wants to make everything :integer or AUTOINCREMENT.
>>>
>>
>> The docs seem to indicate that you can use arbitrary PK's:
>>
>> http://sequel.rubyforge.org/classes/Sequel/Schema/Generator.ht...
>>
>> So, if int is enforced there is a bug - either in your code or in Sequel's
>> code.
>>
>> Kind regards
>>
>> robert
>>
>>
> Thanks for the input Robert.
>
> It turns out there is a rather vaguely documented :auto_increment => false
> that needed to be included in my primary_key definition. Now I just need to
> figure out how to get foreign_keys to work. The sequel-talk group seems to
> be working so I will continue this pursuit there.
>
> Thanks again.
>
> --
> "Hey brother Christian with your high and mighty errand, Your actions speak
> so loud, I can't hear a word you're saying."
>
> -Greg Graffin (Bad Religion)

I don't want to hijack this thread, and people may be mad about me
saying this again. Will you (that would be people in general and
doesn't include Greg as far as I can see) please stop using
auto_increment as a guarantee of uniqueness in a database/set?! The
set theory should be handled in the db anyway, IMHO.

It's convenient, but think, for example, if you move a postresql db
schema to oracle, or vice versa, or even worse to SQLite (nothing
against you guys, I think you have a really cool product and am
looking forward to future updates). Anyways, "Uh-oh." "Price is
Right" ... buy another key so we can move on. Silly. This is how
mud/clay is added to structures because people think they are being
practical engineers.

Ruby is good stuff. Let's use it in a good way! Likewise, the
databases need to be used correctly.

Todd

Robert Klemme

6/25/2008 5:32:00 AM

0

On 24.06.2008 20:13, Glen Holcomb wrote:
> [Note: parts of this message were removed to make it a legal post.]
>
> On Tue, Jun 24, 2008 at 11:03 AM, Robert Klemme <shortcutter@googlemail.com>
> wrote:
>
>> On 24.06.2008 18:01, Glen Holcomb wrote:
>>
>>> I posted to the Sequel Google Group but it's horribly slow, assuming it
>>> took
>>> my post.
>>>
>>> Does anyone on here know if it is possible to create a non-integer primary
>>> key in Sequel? If so how? Also help with creating a non integer foreign
>>> key would be great too. I've done some poking through the Rdoc and some
>>> experimentation and it wants to make everything :integer or AUTOINCREMENT.
>>>
>> The docs seem to indicate that you can use arbitrary PK's:
>>
>> http://sequel.rubyforge.org/classes/Sequel/Schema/Generator.ht...
>>
>> So, if int is enforced there is a bug - either in your code or in Sequel's
>> code.
>>
> Thanks for the input Robert.

You're welcome.

> It turns out there is a rather vaguely documented :auto_increment => false
> that needed to be included in my primary_key definition. Now I just need to
> figure out how to get foreign_keys to work.

I have seen this documented in the docs. Does it not work as advertised?

> The sequel-talk group seems to
> be working so I will continue this pursuit there.

Good chances that you get more profound feedback there.

Cheers

robert

Glen Holcomb

6/25/2008 2:30:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Tue, Jun 24, 2008 at 11:33 PM, Robert Klemme <shortcutter@googlemail.com>
wrote:

> On 24.06.2008 20:13, Glen Holcomb wrote:
>
>> [Note: parts of this message were removed to make it a legal post.]
>>
>> On Tue, Jun 24, 2008 at 11:03 AM, Robert Klemme <
>> shortcutter@googlemail.com>
>> wrote:
>>
>> On 24.06.2008 18:01, Glen Holcomb wrote:
>>>
>>> I posted to the Sequel Google Group but it's horribly slow, assuming it
>>>> took
>>>> my post.
>>>>
>>>> Does anyone on here know if it is possible to create a non-integer
>>>> primary
>>>> key in Sequel? If so how? Also help with creating a non integer
>>>> foreign
>>>> key would be great too. I've done some poking through the Rdoc and some
>>>> experimentation and it wants to make everything :integer or
>>>> AUTOINCREMENT.
>>>>
>>>> The docs seem to indicate that you can use arbitrary PK's:
>>>
>>> http://sequel.rubyforge.org/classes/Sequel/Schema/Generator.ht...
>>>
>>> So, if int is enforced there is a bug - either in your code or in
>>> Sequel's
>>> code.
>>>
>>> Thanks for the input Robert.
>>
>
> You're welcome.
>
> It turns out there is a rather vaguely documented :auto_increment => false
>> that needed to be included in my primary_key definition. Now I just need
>> to
>> figure out how to get foreign_keys to work.
>>
>
> I have seen this documented in the docs. Does it not work as advertised?
>

I didn't run across it in my initial search. The pirmary_key method
doc says to see column for available options. There is no :auto_increment
listed in the valid options for column. It is logical that it would exist
but I didn't see it in the doc. At least it didn't appear in a straight
forward manner.


>
> The sequel-talk group seems to
>> be working so I will continue this pursuit there.
>>
>
> Good chances that you get more profound feedback there.
>

Turns out Jeremy was having to approve my messages to the Google Group/list
which explains why it appeared to be acting oddly.


>
> Cheers
>
> robert
>
>


--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

Dave Bass

6/25/2008 5:42:00 PM

0

Glen Holcomb wrote:
> Does anyone on here know if it is possible to create a non-integer
> primary
> key in Sequel?

If you mean a floating-point primary key, that doesn't sound like a good
idea, for the same reason that doing == comparisons with floats isn't a
good idea.
--
Posted via http://www.ruby-....

Glen Holcomb

6/25/2008 5:57:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Wed, Jun 25, 2008 at 11:41 AM, Dave Bass <davebass@musician.org> wrote:

> Glen Holcomb wrote:
> > Does anyone on here know if it is possible to create a non-integer
> > primary
> > key in Sequel?
>
> If you mean a floating-point primary key, that doesn't sound like a good
> idea, for the same reason that doing == comparisons with floats isn't a
> good idea.
> --
> Posted via http://www.ruby-....
>
>
No, I was looking to do more what Todd was talking about. I've never seen
any reason to generate a pointless counter for a key and in analog extra
constraints when the DBMS handles it for you simply by working in sets (and
in some cases bags). If my DB is a model of real world entities as it
should be then there should be a unique indentifier for said entities which
means I shouldn't have to number them just because.

In other words I am using necessary table elements as keys.

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

Rimantas Liubertas

6/25/2008 6:12:00 PM

0

<...>
> If my DB is a model of real world entities as it
> should be then there should be a unique indentifier for said entities which
> means I shouldn't have to number them just because.
>
> In other words I am using necessary table elements as keys.

The problem with "real world" unique identifiers is that even if they
stay uniqui they
_may_ change. The worst part it that they do change, even those you though would
never ever possible change.
Surrogate keys do not have this problem. They may have other problems,
but it is worth it,
imho.

Regards,
Rimantas
--
http://rim...

Glen Holcomb

6/25/2008 8:51:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Wed, Jun 25, 2008 at 12:12 PM, Rimantas Liubertas <rimantas@gmail.com>
wrote:

> <...>
> > If my DB is a model of real world entities as it
> > should be then there should be a unique indentifier for said entities
> which
> > means I shouldn't have to number them just because.
> >
> > In other words I am using necessary table elements as keys.
>
> The problem with "real world" unique identifiers is that even if they
> stay uniqui they
> _may_ change. The worst part it that they do change, even those you though
> would
> never ever possible change.
> Surrogate keys do not have this problem. They may have other problems,
> but it is worth it,
> imho.
>
> Regards,
> Rimantas
> --
> http://rim...
>
>
I'm curious as to when and why it matters if a primary key is mutable or
not. As long as it is still unique and any necessary side-effects are
handled either by the app or the DBMS.

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

Rimantas Liubertas

6/26/2008 7:33:00 AM

0

> I'm curious as to when and why it matters if a primary key is mutable or
> not. As long as it is still unique and any necessary side-effects are
> handled either by the app or the DBMS.

Well, the first time you have to handle those side effects in your
app you will see why it matters :)


Regards,
Rimantas
--
http://rim...