Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6364833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:12:54+00:00 2026-05-25T00:12:54+00:00

Got a question for some of you rails guru’s out there. I am developing

  • 0

Got a question for some of you rails guru’s out there. I am developing what will ultimately become a rails3 app, based on a MySQL database. The problem with my app is the way my database is set up. In my rails experience thus far, using standard scaffolding to get my models up and running has worked just fine. Each model gets a single unique ID for each record (PK), and as long as the model names match the attribute names in the database table everything goes well.

This time, the database I am building my app around has already been created and each table uses a combination of two or three columns to form the primary keys. Here is my question… how do you set up a model using ActiveRecord to use a combination of primary keys to identify records properly and manipulate model objects the way I did when there was a single PK?

Thanks for the tips

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:12:55+00:00Added an answer on May 25, 2026 at 12:12 am

    I would recommend continuing to use a single, integer primary key for the primary table and for relationships. You can create one (or more) ‘alternate keys’ (or unique indexes) to make sure that they remain unique.

    Also, try to avoid using data elements as your primary keys. This creates complexities if the data used for the key changes (which seems to happen most on keys that you originally believe would never change).

    Having said that, there’s a great article on non-standard primary keys: http://roninonrails.blogspot.com/2008/06/using-non-standard-primary-keys-with.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a question: In my Android app there is an activity containing a
(I asked this question in another way , and got some interesting responses but
I've got a really simple rails question here but I can't seem to find
I've got a fancy-schmancy worksheet style view in a Rails app that is taking
Ok this is something weird. I got authlogic-oid installed in my rails app today.
We are using TFS 2010 with gated checkins. I've got some question about what
got a question regarding printing out the 128 first characters from the ascii table.
I got some question is using ASIHTTPRequest to tracking Upload/Download progress This is the
I want to share some question in which i got confused. Please check. :-)
Unusual interview question I got. Being completely agnostic about the platform, what are some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.