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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:02:01+00:00 2026-05-12T07:02:01+00:00

What I mean is, If I had the following schema: create table tableA( A_id

  • 0

What I mean is, If I had the following schema:

create table tableA(
    A_id   number not null primary key
);

create table tableB(
    B_id   number not null primary key,
    A_id   number not null references tableA(A_id),
    B_data text   not null
);

create table tableC(
    C_id   number not null primary key,
    A_id   number not null references tableA(A_id),
    C_data text   not null
);

If I wanted to retrieve B_data and C_data using the relationships described here, is there any difference between the following:

select
    b.B_data,
    c.C_data
from
    tableB b
    inner join tableC c
        on b.A_id = c.A_id;

and:

select
    b.B_data,
    c.C_data
from
    tableB b
    inner join tableA a
        on b.A_id = a.A_id
    inner join tableC c
        on a.A_id = c.A_id;

I suspect that most databases will optimise either query to be the same, but are there cases where the foreign key constraints to tableA will make joining via tableA much more efficient? Are there any cases where these queries could produce different results?

  • 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-12T07:02:01+00:00Added an answer on May 12, 2026 at 7:02 am

    You may as well join them directly. Foreign key constraints don’t do anything to make joins more efficient; indexes do that, which (depending on DBMS) may be a separate matter from foreign keys. Either way, if there’s an index to work with, you have it regardless of whether you’re going by your foreign key.

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

Sidebar

Related Questions

I have the following table, which enforces a foreign key on vendor_id : CREATE
What does the >> sign mean in Java? I had never seen it used
So if I have a CSS class named class-name, what does the following mean?
I had always used something similar to the following to achieve it: INSERT INTO
I got the following error in Delphi 2007. What does it mean? [DCC Error]
Ok, So I have the following situation. I originally had some code like this:
In a single node setup I had auto-generated unique key by using UUID: <field
I am not a Haskell pro. Today I had a somewhat bizarre experience with
I am learning some aspx and had a question. I have the following example
I mean I have one line and I want to put 2 spinner in

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.