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 3790804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:22:17+00:00 2026-05-19T12:22:17+00:00

Is the following kosher? schema.rb users id:int (autoincr.) uid:string <—————- … fb_friends id:int (autoincr.)

  • 0

Is the following kosher?

schema.rb
  users
    id:int (autoincr.)
    uid:string <----------------
    ...

  fb_friends
    id:int (autoincr.)
    uid:int <-------------------
    friend_uid:int
    ...

user.rb
   has_many :fb_friends, :primary_key => "uid", :foreign_key => "uid"

Note that the keys that tie a “user” and their “fb_friends” together are of different data types (string and int). In an ideal world, I probably wouldn’t do this, but given the current system architecture, this seems to be the solution that would work best.

But is this okay to do / will it work without snafoos?

  • 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-19T12:22:18+00:00Added an answer on May 19, 2026 at 12:22 pm

    It depends on the DB engine you’re using, e.g, for mysql =>

    Corresponding columns in the foreign
    key and the referenced key must have
    similar internal data types inside
    InnoDB so that they can be compared
    without a type conversion. The size
    and sign of integer types must be the
    same. The length of string types need
    not be the same. For nonbinary
    (character) string columns, the
    character set and collation must be
    the same.

    More info here, Anyways, I won’t say it’s a good practice to compare fields of different types :(.

    Hope it helps you!

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

Sidebar

Related Questions

following code is used to find url from a string with php. Here is
Following this python example , I encode a string as Base64 with: >>> import
Following String causes PatternSyntaxException : Pattern.compile(*\\.*); I want to create a pattern so that
Following: <% if ((String) session.getAttribute(userID) != null) { String username= (String) session.getAttribute(userID); %> <li><a><small>Logged
Following code: <?php $test_array = array(); $test_array['string_index'] = data in string index; $test_array[] =
following situation: <body> <div style=position:fixed; width:100%>[place holder for header]</div> <div style=position:relative;width:100%;margin-top:100px>[content]</div> </body> I need
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to
Following are the simple statements in the irb shell. What does nil in the
Following code worked fine abstract class FunctionRunnable<V> implements Runnable { protected abstract V calculate();

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.