# Legacy DB and composite keys: how do you approach?

**URL:** <https://www.ruby-forum.com/t/legacy-db-and-composite-keys-how-do-you-approach/92600>\
**Category:** Rails\
**Created:** [April 21, 2007, 9:51am UTC](https://www.ruby-forum.com/t/legacy-db-and-composite-keys-how-do-you-approach/92600 "2007-04-21T09:51:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![carminem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90db22/32.png) [@carminem](https://www.ruby-forum.com/u/carminem)\
**Post date:** [April 21, 2007, 9:51am UTC](https://www.ruby-forum.com/t/legacy-db-and-composite-keys-how-do-you-approach/92600/1 "2007-04-21T09:51:28Z")

</div>

Hi to everyone,

First a little background noise.

I’m working on an E-Commerce application in Rails and, at this stage,  
I’ve to  
relay on an existing db (MS SQL Server).  
The aforementioned db has all the tables with composite primary (and  
foreign) keys.

So far I’ve been using :conditions on has\_xxx and belongs\_to to overcome  
the problem. I mean, until I found “composite\_primary\_keys” gem.

I’ve installed the gem and it doesn’t work with MS SQL.  
The error is “uinitialized constant” at some point.

Putting that aside, I would like to know how do you usually approach the  
composite primary key issue.

Thanks in advance for your help.  
Regards,  
Carmine
