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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:43:25+00:00 2026-06-15T07:43:25+00:00

I have two tables, Table A and Table B. Now table A has A.id

  • 0

I have two tables, Table A and Table B.

Now table A has A.id and B has B.id whereby B.id is the foreign key to link with A.id

Now my problem is, A has A.extraid that “HAS” many rows in B wherein the column name is B.notsamextraid. In other words, the values of B.notsamextraid matches the values of A.extraid

What should I do in order to have Yii match these two columns wherein they both have different names ?

(I am not authorize to alter the name of B.notsamextraid into B.extraid)

  • 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-06-15T07:43:27+00:00Added an answer on June 15, 2026 at 7:43 am

    The Yii documentation says DO define foreign-key relationships in the database schema.

    Can you try out the following tables? Yii should be able to pick up both foreign keys:

    create table a (
      id      int not null primary key,
      extraid int not null unique
    );
    
    create table b (
      id            references a(id),
      notsamextraid references a(extraid)
    );
    

    Edit: To find out if there are already foreign keys between two tables, you can use the following query. It’s not the prettiest query on the planet, but then there is copy and paste 🙂

    select t1.owner, t1.constraint_name, t1.constraint_type, t1.table_name, c1.column_name,
           t2.owner, t2.constraint_name, t2.constraint_type, t2.table_name, c2.column_name
      from all_constraints  t1
      join all_cons_columns c1
        on t1.constraint_name=c1.constraint_name
       and t1.owner=c1.owner 
       and t1.table_name=c1.table_name
      join all_constraints  t2
        on t1.owner=t2.owner
       and t1.r_constraint_name=t2.constraint_name
      join all_cons_columns c2
        on t2.constraint_name=c2.constraint_name
       and t2.owner=c2.owner 
       and t2.table_name=c2.table_name
       and c1.position=c2.position
     where t1.constraint_type = 'R'
       and t1.table_name in ('A','B');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large table (~1M rows now, soon ~10M) that has two ranked
I have two tables that are connected via a Foreign Key. In table A
I have a city table that has two columns from_city to_city now lets assume
Hi Guys I have two tables table B has a many to 1 relationship
I have two tables, Parent and Child. The column Parent.favorite_child has a foreign key
I have two tables. One table A has n rows of data and the
I have two tables : DISH and DISH_HAS_DISHES. Dish table has all the dishes
I have two tables, each one has a primary ID column as key. I
I have two tables on mysql: users, and management. The users table has a
I have two tables in my database. TableOne has theKey primary key. TableTwo has

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.