On 2/18/06, Dae San Hwang <[EMAIL PROTECTED]> wrote:
> Thank you for the reply!
>
> I especially liked your analogy of ID to memory address though I'm
> not yet 100% convinced.  Following are my reasonings behind the
> preference for multiple integer column id's:
>
> 1. I tend to think URL as a part of the user interface.  If the user
> look at (usually simple and structured in rails application) URL,
> wouldn't she be confused by the seemingly random and very large
> number assigned to her reply post?  Topic's id #87 corresponds to the
> 87th-ness nature of the topic posted in the forum.  Reply id #3 would
> correspond to the 3rd-ness nature of the reply to the given topic,
> reply id #1074 would not.  I know, I know, I might sound like someone
> who is suffering ocd..  ;)
>
> 2. This one is a bit more practical issue.  Let's say I'm building a
> public forum hosting service.  (It is indeed something I have in
> mind.)  At some point, my site hosts 10,000 forums, each having its
> own forum_id.  Let's say each forum has average of 10,000 topics,
> each having its own topic_id.  And each topic has average of 100
> replies, each having its own reply_id.  If I have to use a flat
> integer id space, there will be replies with id like #10,000,000,000.
> (10,000 * 10,000 * 100)  Now, 32-bit unsigned integer can't handle it
> since its max value would 4,294,967,295.  I could just use 64-bit
> unsigned integer, I guess, but it does take more spaces and what if
> my site becomes even more successful to the extent even 64-bit
> integer will max out?
>
> In some ways, id's are like memory addresses, but no user ever get to
> see the memory address values..  Are there other reasons against the
> use of multiple integer column id's other than the fact that
> ActiveRecord doesn't support it?
>
> Thanks,
>
> daesan
>
>
> On Feb 19, 2006, at 2:57 AM, Michael Koziarski wrote:
>
> > On 2/18/06, Dae San Hwang <[EMAIL PROTECTED]> wrote:
> >> Hi,
> >>
> >> As I understand, composite primary keys aren't supported in
> >> ActiveRecord yet.  May I ask if there are plans for this feature?
> >> Better yet, if this feature is under development, how's the progress
> >> going?
> >
> > There is currently no work underway to support composite keys with
> > active record.  At least in rails itself.  There might well be some
> > plugins under development.
> >
> >> I'm not trying to use legacy databases.
> >
> > Then stick with surrogate ids
> >
> >> I tend to think that using
> >> multiple integer column id's (composite primary key) are often
> >> natural way to implement one-to-many relationships, for things like
> >> "forum replies".  For example, ID for the third comment of forum
> >> topic #87 should be (87, 3) not (87, 1074), format being (topic_id,
> >> reply_id).
> >
> > You shouldn't be thinking about the IDs,  they're only there for the
> > sake of persistance,  consider them the logical equivalent of an
> > address in memory.  It doesn't matter what the number is,  just that
> > there *is* a number.
> >
> >
> >
> >
> > --
> > Cheers
> >
> > Koz

map.connect 'topic/:topic/:reply'

/topic/87/3

@reply = Reply.find_by_topic_id_and_id(params[:topic], params[:reply])

--
Rick Olson
http://techno-weenie.net
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to