OT: Why would you ever use numbers instead of strings for ids?

David Bovill david.bovill at gmail.com
Sat Sep 21 15:31:13 EDT 2013


Thanks for the input - and the article. Seems right. Artificial / surrogate
traditionally incremental integers moving over to hash based UUID's


On 20 September 2013 14:52, Geoff Canyon <gcanyon at gmail.com> wrote:

> On Thu, Sep 19, 2013 at 5:46 AM, David Bovill <david.bovill at gmail.com
> >wrote:
>
> >
> >    1. No good reason - historical
> >    2. ID lookups tend to be faster
> >    3. Some scenarios allow you to derive meaning from incremental
> increases
> >    in the number - ie it is the next in a series
> >
> > Naturally in Livecode the difference between numbers and strings is
> > deliberately and unusually blurred. Still in general it always seemed to
> me
> > that reasons 2 & 3 were insufficient. Can someone explain why on earth
> the
> > Twitter API does not just use screen names ( a unique lower case string
> of
> > 15 chars without spaces) - what is the advantage of also having a 16
> > integer number?
>
>
>
> I'm not a DBA, but I'll take a swing at this.
>
> 1. Databases have auto-increment for numeric keys. It would require work to
> do the same thing with strings.
> 2. Numeric keys are efficient -- both compact and fast. Maybe not as
> important these days, but still a consideration.
> 3. Context does matter, so the fact that I can look at a row with a key of
> 12345 and know  that rows created around the same time will have similar
> numbers is useful, even if the table also has columns for the creation
> date.
>
> Finally -- I'm a purist, but primary keys should never be based on actual
> data. In other words, they should be artificial -- some say surrogate.
> Here's
> an essay on keys <http://www.agiledata.org/essays/keys.html>. I only
> skimmed it, but it looks reasonable.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list