Re: Composite Key

Mark Reginald James
Sat, 15 Oct 2005 02:14:02 -0000

Ron DiFrango wrote:

> Now, I could add a column that is an ID column to the table, but in my mind
it is a waste of space because it is nothing more than a placeholder just to
satisfy RoR.
>
> I will say that in most if not all the enterprise app I have worked on we
have had Composite Keys that in my opinion were absolutely necessary and fall
under this category where you are combining keys from either multiple tables or
there unique combinations yeilded something different.  I think for RoR to truly
succeed, it needs built-in support for not only Composite Keys, but quite
possibly those that are character based as well.

I agree support for composite keys is desirable.  One solution I''ve
used when a table has a natural composite key and I don''t want the
waste of a separate auto-increment id is to forgo making the table
into a model and instead read data from the table into attributes
of an actual model by running find_by_sql queries on that model.

--
We develop, watch us RoR, in numbers too big to ignore.