Comments on: Rails with foreign key constraints http://blog.amber.org/2006/05/01/rails-with-foreign-key-constraints/ Thoughts of a minor lunatic Wed, 21 Oct 2009 01:55:36 +0000 http://wordpress.org/?v=2.9.2 hourly 1 By: Lawrence http://blog.amber.org/2006/05/01/rails-with-foreign-key-constraints/comment-page-1/#comment-10580 Lawrence Wed, 14 Jun 2006 05:51:20 +0000 http://blog.amber.org/2006/05/01/rails-with-foreign-key-constraints/#comment-10580 I agree as well -- I would have migrated from a legacy PHP-wrapped system already, but I expected Rails to be more sensible about foreign keys. I agree as well—I would have migrated from a legacy PHP-wrapped system already, but I expected Rails to be more sensible about foreign keys.

]]>
By: John http://blog.amber.org/2006/05/01/rails-with-foreign-key-constraints/comment-page-1/#comment-6910 John Tue, 09 May 2006 12:06:28 +0000 http://blog.amber.org/2006/05/01/rails-with-foreign-key-constraints/#comment-6910 I totally agree with you on the MySQL influence on Rails, which I think otherwise is a fantastic framework. I'm developing a do-over of a fairly complex system from PHP/Postgresql in Rails, and so far the biggest snag I've run into is the way that Rails assumes I am building columns such as "Type", and "Status" into my tables as simple varchars. This is the wrong way to do it. Instead, "Type" and "Status" columns should be integers referencing foreign keys in respective "Types" and "Statuses" tables. The application code should never be responsible for data integrity at this level. Not only should the database do this, it's built to do it. What this means for me in Rails, is that many of the nice automagic features, such as Single Table Inheritance, only half-work. I am however starting to think about patching ActiveRecord to support a more proper way of doing things. I totally agree with you on the MySQL influence on Rails, which I think otherwise is a fantastic framework.

I’m developing a do-over of a fairly complex system from PHP/Postgresql in Rails, and so far the biggest snag I’ve run into is the way that Rails assumes I am building columns such as “Type”, and “Status” into my tables as simple varchars. This is the wrong way to do it. Instead, “Type” and “Status” columns should be integers referencing foreign keys in respective “Types” and “Statuses” tables. The application code should never be responsible for data integrity at this level. Not only should the database do this, it’s built to do it.

What this means for me in Rails, is that many of the nice automagic features, such as Single Table Inheritance, only half-work.

I am however starting to think about patching ActiveRecord to support a more proper way of doing things.

]]>