Linked by Thom Holwerda on Fri 7th Dec 2007 19:44 UTC, submitted by Bill Davenport
Permalink for comment 289455
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.





Member since:
2005-07-22
You only need compound primary keys if you want to use a legacy database.
If you are designing a database for a Rails app from scratch you are still expected to have a column called 'id' that is the primary key in each table.
Now that the ids of rows are used to build up the RESTful urls, it has become harder to not use this convention. For example, if you have a url of /posts/1/comments/3 the '1' and the '3' are the primary keys of the post and the comment. If they were compound primary keys, you would probably end up with a pretty messy looking url. As well as needing to special case the models for compound primary keys, you would also need to special case the config/routes.rb file that generates the urls.