Foreign keys in Ruby on Rails

Should the foreign key constraints only be declared in the Model code of
the application, or in both the code and the database?

spambak wrote:

Should the foreign key constraints only be declared in the Model code of
the application, or in both the code and the database?

Why not ask on the Rails list?

If your database can be used from other programs, you want the
constraints to exist in the database (so they can’t be broken by other
software that ignores them). Otherwise, it seems to me, it’s just
overhead.

You could say that about any validation logic you write into your model
(or get for free from ActiveRecord) – perhaps it should be duplicated
by validation triggers in your database, so that other code can’t mess
it up – but when you do that, you seem to lose a large amount of the
advantage of Rails over other web-database frameworks.

Good luck…