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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:58:09+00:00 2026-05-10T23:58:09+00:00

I find this comes up a lot, and I’m not sure the best way

  • 0

I find this comes up a lot, and I’m not sure the best way to approach it.

The question I have is how to make the decision between using foreign keys to lookup tables, or using lookup table values directly in the tables requesting it, avoiding the lookup table relationship completely.

Points to keep in mind:

  • With the second method you would need to do mass updates to all records referencing the data if it is changed in the lookup table.

  • This is focused more towards tables that have a lot of the column’s referencing many lookup tables.Therefore lots of foreign keys means a lot of joins every time you query the table.

  • This data would be coming from drop down lists which would be pulled from the lookup tables. In order to match up data when reloading, the values need to be in the existing list (related to the first point).

Is there a best practice here, or any key points to consider?

  • 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. 2026-05-10T23:58:10+00:00Added an answer on May 10, 2026 at 11:58 pm

    You can use a lookup table with a VARCHAR primary key, and your main data table uses a FOREIGN KEY on its column, with cascading updates.

    CREATE TABLE ColorLookup (   color VARCHAR(20) PRIMARY KEY );  CREATE TABLE ItemsWithColors (   ...other columns...,   color VARCHAR(20),   FOREIGN KEY (color) REFERENCES ColorLookup(color)     ON UPDATE CASCADE ON DELETE SET NULL ); 

    This solution has the following advantages:

    • You can query the color names in the main data table without requiring a join to the lookup table.
    • Nevertheless, color names are constrained to the set of colors in the lookup table.
    • You can get a list of unique colors names (even if none are currently in use in the main data) by querying the lookup table.
    • If you change a color in the lookup table, the change automatically cascades to all referencing rows in the main data table.

    It’s surprising to me that so many other people on this thread seem to have mistaken ideas of what ‘normalization’ is. Using a surrogate keys (the ubiquitous ‘id’) has nothing to do with normalization!


    Re comment from @MacGruber:

    Yes, the size is a factor. In InnoDB for example, every secondary index stores the primary key value of the row(s) where a given index value occurs. So the more secondary indexes you have, the greater the overhead for using a ‘bulky’ data type for the primary key.

    Also this affects foreign keys; the foreign key column must be the same data type as the primary key it references. You might have a small lookup table so you think the primary key size in a 50-row table doesn’t matter. But that lookup table might be referenced by millions or billions of rows in other tables!

    There’s no right answer for all cases. Any answer can be correct for different cases. You just learn about the tradeoffs, and try to make an informed decision on a case by case basis.

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

Related Questions

Loading...

Sidebar

Ask A Question

Stats

  • Questions 55k
  • Answers 55k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I just think of it as a pointer to a… May 11, 2026 at 7:48 am
  • added an answer It looks like its a fairly intensive process. First set… May 11, 2026 at 7:48 am
  • added an answer What I would do is: Set up separate virtual hosts… May 11, 2026 at 7:48 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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.