Hi, I need to support a legacy database that mostly uses clustered
primary keys (i.e. every primary key consiststs of multiple fields not
just a single one. E.g. if I have tables A,B and C and C depends on
tables A and B, then C’s primary key will consist of 3 or more fields-
the foreign key fields pointing to A and B and a field or fields from C
that will make C unique- in combination with the fk fields). This is
also a very typical database schema design ‘pattern’ and implementation.
I just want to make sure about the following fact: Rails doesn’t support
clustered primary keys.
(The active record method: ‘set_primary_key’ accepts a single field name
only)Do I have it right?
I plan to deal with this by ‘converting’ the current clustered primary
keys to clustered secondary indixes and then add rails’ default ‘id’
field as the primary key. In this way the db engine can still enforce
referencial integrity and I can use Rails. I’m not sure the client dba
will like this however.
It seems that most database persistence frameworks, e.g. Hibernate
support clustered primary keys. I’ve also seen other activerecord
implementations that support this. So I’m wondering why rails doesn’t
support this- it is a very basic/common need. Is this something that
might be added in future or is there a good reason to not want it?