[Facebooker-talk] Overriding id with facebook_id???
Mike Mangino
mmangino at elevatedrails.com
Tue Nov 11 11:15:45 EST 2008
On Nov 11, 2008, at 4:36 AM, Joseph Durden wrote:
> I am new to rails, and was wondering if there would be unknown
> consequences for setting the user tables primary key to being the
> facebook_id of a user. I have implemented this funcionality, and
> everything is working fine. All associations etc. What are the
> risks if there are any of overridding the id with facebook_id? Why
> would I not want to do this? I did this because, it seems easier to
> look up a user by their facebook id rather than their id to get
> their facebook id in associated table. Meaning if I have an
> association with a user has_many comments, and the comments has a
> user_id column. I think it is easiers looking up things with
> facebook_ids rather than ids, as these can get confusing. just one
> less thing to worry about.
The typical reason for using a surrogate key is to guard against
changes. In this case, there is a very low probability that Facebook
will change the id of a user, so that's not a big deal.
What might be a bigger deal is supporting other platforms. If you
choose to use the facebook_id as the primary key, what would happen if
you wanted to add BEBO support?
Mike
>
>
> Does it matter what the order of insertions to the database for
> creating new Users?
>
> Any insight would be wonderful.
>
> Graciously,
>
> Joe
> _______________________________________________
> Facebooker-talk mailing list
> Facebooker-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/facebooker-talk
--
Mike Mangino
http://www.elevatedrails.com
More information about the Facebooker-talk
mailing list