On Oct 6, 10:44 pm, "Pardee, Roy" <[EMAIL PROTECTED]> wrote:
> I'd make that "or there are other apps that *will ever* update the database".
> Also, if you use SQL to change data (and I'd include stuff like update_all
> and delete_all calls) you may well appreciate having the protection of FKs.
>
> I may fit that "paranoid" description... ;)
I'm well and truly in there. App level constraints are not hard
constraints in the sense that a unique index or a foreign key are:
they do suffer from race conditions.
Fred
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
> Of Rob Biedenharn
> Sent: Monday, October 06, 2008 2:14 PM
> To: [email protected]
> Subject: [Rails] Re: Should I create foreign keys on my database?
>
> On Oct 6, 2008, at 5:06 PM, elioncho wrote:
> > Hello,
>
> > I have a dilemma. Should I create foreign keys on my database or
> > should I let the app models do all the work?
>
> > Thanks,
>
> > Elioncho
>
> If the Rails app is the only thing hitting the database, then let
> ActiveRecord handle it.
>
> If you're paranoid or there are other apps updating the database, then go for
> the safety-net.
>
> In any case, you certainly want indexes on your *_id columns if there is a
> has_many that uses it. (I.e., on the bars.foo_id column if Foo has_many
> :bars)
>
> -Rob
>
> Rob Biedenharn http://agileconsultingllc.com
> [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---