Have been looking into using rails but am finding the "Composite
Primary Keys are Bad" thing a tad disturbing (to put it mildly). I
have been working with RDBMS systems for over fifteen years and this
is the first time I have herd the idea questioned. I have cone across
using surrogate keys which mirror the composite key for performance
reasons in VERY big databases but I have never herd the idea
questioned from a logical database design point of view. Apart from
it being easier in rails to use non composite keys has anyone got any
other good reasons not to use them. As far as I am concerned they are
fundamental to RDBMS.
Regards,
Ben
Ben Edwards wrote:
Have been looking into using rails but am finding the "Composite
Primary Keys are Bad" thing a tad disturbing (to put it mildly). I
have been working with RDBMS systems for over fifteen years and this
is the first time I have herd the idea questioned. I have cone across
using surrogate keys which mirror the composite key for performance
reasons in VERY big databases but I have never herd the idea
questioned from a logical database design point of view. Apart from
it being easier in rails to use non composite keys has anyone got any
other good reasons not to use them. As far as I am concerned they are
fundamental to RDBMS.
They are fundamental to RDBMSes. The problem is that they don't map so well from the relational world to the object world so ORMs have to go through convolutions to handle them. That's why if you are creating a "green field" application the recommendation is to use a single column as the unique key.
This problem is not unique to ActiveRecord. If you look at something Hibernate, it does support composite primary keys but you have to define your own "equality" method, even after you specify what columns make up the composite key.
Ben Edwards wrote:
Have been looking into using rails but am finding the "Composite
Primary Keys are Bad" thing a tad disturbing (to put it mildly). I
have been working with RDBMS systems for over fifteen years and this
is the first time I have herd the idea questioned. I have cone across
using surrogate keys which mirror the composite key for performance
reasons in VERY big databases but I have never herd the idea
questioned from a logical database design point of view. Apart from
it being easier in rails to use non composite keys has anyone got any
other good reasons not to use them. As far as I am concerned they are
fundamental to RDBMS.
Ben,
you can use composite primary keys in Rails. See http://compositekeys.rubyforge.org/