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

The Archive Base Latest Questions

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

Guys i currently have 2 tables that reference a lookup table. Ive been tasked

  • 0

Guys i currently have 2 tables that reference a lookup table. Ive been tasked with modifiying the database to allow the tables to reference more than one value in the lookup table.

My idea is to create a new table that has a new PK and a column that references the lookup table. The PK of the new table is then dumped into the parent tables thus maintaining referential integrity E.G

Current

 Contracts
 =========
 PK Id
 FK lookupId

 Warranties
 ==========
 PK Id
 FK lookupId

New

 Contracts
 =========
 PK Id
 FK LinkingTableId

 Warranties
 ==========
 PK Id
 FK LinkingTableId

 LinkingTable
 ============
 PK Id
 FK LookupId

Is this a good way of handling the multiple references?

  • 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-24T09:12:03+00:00Added an answer on May 24, 2026 at 9:12 am

    Your NEW proposed table structure cannot handle multiple references, because each Contract and Warranty row is linked to just one single LinkingTable row.

    I see two ways to do this:

    1. Add two distinct linking tables, one for each many-to-many relationship:

      Contracts
      =========
      PK Id
      Other_Contract_Stuff
      
      ContractLinkingTable
      ====================
      PK ContractId, LookupId
      FK ContractId
      FK LookupId
      
      Warranties
      ==========
      PK Id
      Other_Warranty_Stuff
      
      WarrantyLinkingTable
      ====================
      PK WarrantyId, LookupId
      FK WarrantyId
      FK LookupId
      
    2. Add a single new linking table, to handle both many-to-many relationships:

      Contracts
      =========
      PK Id
      Other_Contract_Stuff
      
      Warranties
      ==========
      PK Id
      Other_Warranty_Stuff
      
      LinkingTable
      ====================
      PK LinkedType, LinkedId, LookupId
         LinkedType ("C" for Contract, "W" for Warranty)
         LinkedId (either a ContractId or a WarrantyId)
      FK LookupId
      

    The first is the correct and preferrable solution, as the engine can enforce the table foreign keys and data integrity is less at risk. I have seen the latter used in some real world projects. It works, but it is not a good solution… and sooner or later you will have problems with it.

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

Sidebar

Related Questions

Hey guys, I currently have a root table view which has a toolbar at
Hey guys, quick question. I have a table of messages. There are two types
guys. Say I have the following table: ID | String ---+--------- 1 | <123><345>
Hey guys, I'm currently trying to implement a function using C that takes in
.Hi guys, i need a little help with a project that i'm currently working
Guys, I’ve been writing code for 15+ years, but managed to avoid Web Development
Ok guys just a small game: I have some specifications for a project. At
Hi Guys could you please help me refactor this so that it is sensibly
Ok guys and gals, here is my problem: I've built a custom control that
Hi guys I wrote this code and i have two errors. Invalid rank specifier:

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.