Is there any reason why AR has never supported foreign-key constraints?

I can understand the lack of support for triggers and stored procedures since they are highly dependent on the database to create a wrap API around them. But this is not the case for foreign keys.

This is specially important for open-source projects like Redmine/Chiliproject and Gitorious where you shouldn't be assuming what database is going to be chosen in the end point.

Besides that, the recommended way of creating a database is through rake db:setup, which does that by reading the schema.rb DSL. Does this DSL support foreign keys?

I think this is fundamentally wrong in ActiveRecord design and should be considered as high-priority since foreign keys are a key concept in RDBMS.

I guess most Rails applications out there are doing this the wrong way by not creating foreign keys at all, which is a huge mistake. This may be helped by the fact that most Rails application chose MySql for some reason and one of its dialect does not support foreign keys.

I'm really surprised that Rails still has some fundamental flaws like:

1 - the lack of foreign-key constraints support in schema.rb and migration helpers;
2 - not considering the threaded model to deserve a first-class support;
3 - the lack of support for streaming

While 2 and 3 require a considerable effort to achieve, 1 is easily achievable, by defining an API and DSL for schema.rb. Then, each database maintainer could implement the API translating the proper SQL statement for the foreign key specific methods.

Is there anything I'm missing?

Cheers,

Rodrigo.

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" 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-core?hl=en.

Reply via email to