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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:56:17+00:00 2026-06-05T09:56:17+00:00

We need a solution to the following problem which makes sense an also follows

  • 0

We need a solution to the following problem which makes sense an also follows best practices without making things to complicated.

We have 3 tables which need to be linked, Sector, Location and Company.

ie: A Company “Bobs B&B” is in Sector “Accommodation” which is in Location “New York”.
For hotel groups we could have a single company in multiple sectors across multiple locations.

So we decided to simply create a “CompanySectorLocation” table which has 3 primary keys linking the 3 tables:

CompanySectorLocation
    CompanyID (PK FK)
    SectorID (PK FK)
    LocationID (PK FK)

The curved ball here is that the Location is not required.

ie: “Protea Hotels” is active in the “Accomodation” sector leaving the location as NULL.

My developer is very much against having a table that allows for a NULL FK. His suggestion is to create another table called CompanySector which will deal with the links between Company and Sector where Location is not defined.

CompanySector
    CompanyID (PK FK)
    SectorID (PK FK)

My issue with this is that we will have to maintain 2 tables with effectively duplicate data in them.

What is the best way to do this?

  • 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-05T09:56:19+00:00Added an answer on June 5, 2026 at 9:56 am

    I would create a separate table. I have nothing against NULL FK’s (many people do), but having one table means you’re going to have duplicate data anyway. E.g. if Bob’s B&B opens up a branch in California, you’ll have duplicate entries in the table specifying the relationship between ‘Bob’s B&B’ and ‘Accommodation’. Having a single table also means you’ll have to include DISTINCT in any join on this table only involving the CompanyID and SectorID columns (which seems likely if LocationID is nullable).

    Effectively you will have two many-to-many relationships:

    (Company) <-> (Sector)
    

    and

    (Company/Sector) <-> (Location)
    

    It makes sense to use two linking tables to model two different relationships. If you need all 3 entries in one table (for convenience), you can always create an indexed view.

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

Sidebar

Related Questions

I have the following problem, which seems not to have a nice solution. For
I need a solution for a specific situation. I have an algorithm which basically
I need a solution to this problem: I have a django site that displays
I am faced with the following programming problem. I need to generate n (a,
I need to find a date format which could adapt to the two following
I'm looking for a hacky kind of solution to the following problem: GCC 4.4+
I need a solution on a page.aspx to download file. In database I have
I need some solution to give relative path in my jquery ajax call as
I need a solution to embed a pdf inside a flash screen i.e. want
I need a solution for caching PHP info on a dynamic page AND include

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.