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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:36:29+00:00 2026-05-23T02:36:29+00:00

I have a DB in which there are 4 tables. A -> B ->

  • 0

I have a DB in which there are 4 tables.

A -> B -> C -> D

Current the way I have it is, the Primary Key of A is a foreign key in B. And B would have it’s own Primary Key, which is a foreign key in C, etc etc.

However, C can’t be linked to A without B.

The problem is, a core function of my program involve pulling matching entries from A and D.

Should I include the primary key of A in D too

Doing so will create unnecessary data duplication ‘coz A->B->C->D are hierarchy.
see pic for what D would look like.Proposed Table D

  • 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-23T02:36:30+00:00Added an answer on May 23, 2026 at 2:36 am

    If you take all D-s in relation with given A, I would keep it normalized.

    But if you want specific subset of such D-s and its easy to know which in advance, but time consuming later (eg. if you want all D-s from newest C from newest B), I would prefare storing this shortcut somewhere.

    It does not have to be in D itself (esp. if you don’t want all D-s connected with A).

    If you want to do it to make your queries easier to read and write, then consider view.

    If you want to do it to increase performance, try everything and measure it. (And I’m not expert in performance tuning of SQL, so I have no specific advice beyond that)

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

Sidebar

Related Questions

I have two tables which have some transactional stuff stored in them. There will
I have an existing database with tables which each have 4 partitions (there are
All of my tables have common audit fields: modifiedBy,modifiedDateTime, etc. I would like to
I have three tables which are defined as: class User(Base): __tablename__ = 'users' id
I have a table in which there are two columns : 1. import type,
I have three tables of concern and a query which generates the following output
I have a database table named 'student' in which there is one column named
I have a table which needs to link one of three seperate tables, but
I have Access table with fields, in which there is some data and path
I have a dynamically created table which in the last <td> there is a

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.