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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:19:17+00:00 2026-05-14T01:19:17+00:00

Note I have completely re-written my original post to better explain the issue I

  • 0

Note

I have completely re-written my original post to better explain the issue I am trying to understand. I have tried to generalise the problem as much as possible.

Also, my thanks to the original people who responded. Hopefully this post makes things a little clearer.

Context

In short, I am struggling to understand the best way to design a small scale database to handle (what I perceive to be) multiple many-to-many relationships.

Imagine the following scenario for a company organisational structure:

             Textile Division                    Marketing Division
                    |                                     |
          ----------------------               ----------------------
          |                    |               |                    |
       HR Dept           Finance Dept        HR Dept           Finance Dept
          |                    |               |                    |
      ----------          ----------       ----------           ---------
     |          |         |        |       |        |           |       |
  Payroll     Hiring    Audit     Tax   Payroll   Hiring      Audit  Accounts
     |          |         |        |       |        |           |       |
    Emps      Emps       Emps     Emps    Emps     Emps        Emps    Emps    

NB: Emps denotes a list of employess that work in that area

When I first started with this issue I made four separate tables:

  1. Divisions -> Textile, Marketing (PK = DivisionID)
  2. Departments -> HR, Finance (PK = DeptID)
  3. Functions -> Payroll, Hiring, Audit, Tax, Accounts (PK = FunctionID)
  4. Employees -> List of all Employees (PK = EmployeeID)

The problem as I see it is that there are multiple many-to-many relationships i.e. many departments have many divisions and many functions have many departments.

Question

Giving the database structure above, suppose I wanted to do the following:

  • Get all employees who work in the Payroll function of the Marketing Division

To do this I need to be able to differentiate between the two Payroll departments but I am not sure how this can be done?

I understand that I could build a ‘Link / Junction’ table between Departments and Functions so that I can retrieve which Functions are in which Departments. However, I would still need to differentiate the Division they belong to.

Research Effort

As you can see I am an abecedarian when it comes to database deisgn. I have spent the last two days resaerching this issue, traversing nested set models, adjacency models, reading that this issue is known not to be NP complete etc. I am sure there is a simple solution?

  • 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-14T01:19:17+00:00Added an answer on May 14, 2026 at 1:19 am

    Based on the updated post, and making some (fairly obvious) assumptions based on the names used, I come up with the following. There are four entities:

    • Divisions
    • Departments
    • Functions
    • Entities

    There are many relationships between these entities. Few of them are hierarchical, most are simple associations:

    • Option A1: There is a master list of functions. Every department can perform (or do) one or more function, and a function might be performed by more than on department.
    • Option A2: Functions are “owned” by departments. No function can be performed by two or more departments. (This appears to be the case, as the HR Dept has Payroll and Hiring, and the Finance Dept has Audit, Tax, and Accounts.)

    • Functions are performed by departments for (on behalf of) divisions. (HR Dept does Payroll and Hiring for both Textile and Marketing divisions; Finance Dept does Audit and Tax–but not Accounts–for Textile division, and Audit and Accounts–but not Tax–for Marketing division.) Perhaps a bit more precisely, departments perform selected functions for selected divisions that they are associated with, and that association is defined by their performance of that function.

    • Beyond performing the work of functions, there appears to be no relationship between departments and divisions. There is no hierarchical relationship between them, as one does not “own” or contain the other.

    This leads to these roughly sketched out tables:

    --  Division  -----
    DivisionId  (primary key)
    
    --  Department  ---
    DepartmentId  (primary key)
    
    --  Function  -----  (assumes option A2)
    FunctionId   (primary key)
    DepartmentId (foreign key, references Department)
    
    --  DivisionFunctions  ----
    DivisionId  (First column of compound primary key)
    FunctionId  (Second column of compound primary key)
    

    (You could optionally include a surrogate key to uniquely identify each row, but DivisionId + FunctionId would work.)

    There isn’t enough material here to fully describe how “employees” fit into the model. Given that employees do the work of functions: can an employee do the work of more than one function, or do they only do the one? Does an employee do the work of the function regardless of the division(s) it is being done for, or are they assigned to do the work for one or more divisions? Two obvious options here, though more complex variants are possible:

    • Option B1: Employees do the work of one or more functions within departments, and perform that work for all divisions that require that function of that department.
    • Option B2: Employees are assigned to perform a specific function for a specific division.

    Given these, tables might look like:

    --  Employee  -----  (assumes option B1)
    EmployeeId    (primary key)
    DepartmentId  (foreign key, references Department)
    
    --  EmployeeFunction  -----  (assumes option B1)
    EmployeeId  (First column of compound primary key)
    FunctionId  (Second column of compound primary key)
    

    … and thus all employees that can perform a function will perform it for all divisions requiring it. Or,

    --  Employee  -----  (assumes option B2)
    EmployeeId  (primary key)
    DepartmentId  (foreign key, references Department)
    
    --  EmployeeAssignment  -----  (assumes option B2)
    EmployeeId  (foreign key, references Employee)
    DivisionId  (first of two-column foreign key referencing DivisionFunctions)
    FunctionId  (second of two-column foreign key referencing DivisionFunctions)
    

    (Or, instead of DivisionId and FunctionId, include the optional surrogate key from DivisionFunctions.) … and thus employees are assigned individually to functions to be performed by the department for a division.

    But that still leaves a lot of “what if/when” questions: Do employees “belong to” departments? Can employees belong to (work for) multiple departments? Perhaps employees belong to divisions? Do you track what functions an employee can do, even if they are not currently doing it? Similarly, do you track what department an employee works for, even if they are currently “between functions”? If an employee can perform functions A and B, and a division requires both these functions, might an employee be assigned to only perform A and not B for that division?

    There’s a more requirements research to be done here, but I’d like to think this is a good start.

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

Sidebar

Related Questions

Note - I have not delved very deeply into Apple's iPhone SDK yet. However,
I have the following HTML (note the CSS making the background black and text
I have to give a general note to some huge Java project for which
Note that this function does not have a { and } body. Just a
Note: I am just consuming webservice I have no control over webservice code. So
I have up to 4 files based on this structure (note the prefixes are
I have the VS2005 standard edition and MS says this: Note: The Windows Service
(Note: This is for MySQL's SQL, not SQL Server.) I have a database column
Note: This is the opposite direction to most similar questions! I have an iPhone
Let's say I have a simple stored procedure that looks like this (note: this

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.