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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:19:14+00:00 2026-06-16T16:19:14+00:00

I have almost no experience with backend and database design, so I’m wondering, is

  • 0

I have almost no experience with backend and database design, so I’m wondering, is it good practise to minimize the number of foreign keys in your database?

For example, let’s consider logging on a search website:

USER --hasA--> SESSION --makes--> QUERY

In this case, there is a one-to-many relationship between the user and the session, and the session has a one-to-many relationship with query. It makes sense for session to have a foreign key for the user_id and for query to have a foreign_key for the session_id, but should the query table have a foreign key for the user_id? Why or why not?

Thanks in advance!

  • 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-16T16:19:15+00:00Added an answer on June 16, 2026 at 4:19 pm

    Adding the user_id to QUERY would make the database redundant. That’s why this is mostly bad-practice. It can be necessary as a performance optimization in extreme cases (rarely).

    Minimizing the number of foreign keys is usually not a design goal because it does not help with anything.

    The typical design goal is to have a clean database that models the business domain most naturally. In that sense, don’t add the user_id to QUERY. But absolutely do add all FKs which make sense. This does provide clear and noticeable benefit for development cost and application reliability.

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

Sidebar

Related Questions

I have almost no Perl experience but I was wondering if anyone can point
I admit that I have almost none experience of unittesting. I did a try
Hey, I have almost no experience with Xilinx. I have a group project for
...what does it mean? I have almost no experience with jQuery, and need to
I don't know almost anything about this so if you have some experience let's
I have almost no experience with querying XML data with T-SQL. Given the XML
So I have almost no iphone programming experience, yet I have found some basic
I want to start off by saying that I have almost no experience with
I am an intermediate level programmer with almost no web experience. I have an
I have almost zero experience with random generators. I have used the standard rand

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.