Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

1-Many Relationship X 5

Thought I had a simple project, but as I've gotten into it ... just cant find a solution.  Hopefully it is an easy fix.  I would appreciate any help.

We have 6 Excel spreadsheets that I wanted to import into an Access database in order to create queries & reports.  Each file has common IDs (project) with which to identify the data from table to table.  Sounds simple enough ...  While the initial table (list of projects - Table1) has a Primary Key (ID), the other tables all can list that ID any number of times so I dont have Primary Keys for those tables.  Simplified ...

Table 1 (Project) - ID, Office, Fund
Table 2 (Proj Data) - ID, Priority, Percentage (of Proj) ... i.e. 100% = 1 record; 50%/50% = 2 records etc)
Table 3 (Ops) - ID, Category, Qty, Cost (each item would be a separate record under each project ... same for tables 4,5&6)
Table 4 (Labor) - ID, Employee(s), Hrs, Salary
Table 5 (Vehicles) - ID, License#(s), Cost
Table 6 (Cell phones) - ID, Cell#(s), Cost

I created all of the relationships (1-many from Table 1 to the others) and then created a query based on those relationships.  There were many duplicates and not at all what we wanted.

Next, created individual queries adding one table at a time (i.e. Table 1+2, 1&2+3 etc) and this worked out somewhat better but still not quite right.

Current Output
While this is correct based on what I asked (and there are NO exact duplicates),  In this example (one project), there are 2 priorities (each with its % of project), 0 Ops, 2 Employees, 2 Vehicles and 0 Cell Phones.  There are calculations in the queries which calculate vehicle, salary etc costs based on the % of each priority which works great ... but as you can see, each employee is listed twice under each priority as is each vehicle.

As I said, this is a very simple example ... there are some projects which have up to 5 priorities, 20-30 employees, many vehicles etc.  But, I am very confident that if we can figure out how to format the queries to fix this particular example ... it will carry over to all.

Really appreciate any assistance that you can provide.  Thanks.    
4 Solutions
It is normal for your case - you have "star" structure of tables. When you combine different "beams" in one query - you will get your result. In your case better will be to make report (or form) with subreports for every "beam" (table).
When you have "chain" structure (project-employee-cell#), your queries can work.
Jeffrey CoachmanMIS LiasonCommented:
Try to use more descriptive names for your keys.

Naming them all "ID" is confusing
...make sense...?

I think a sample spreadsheet and DB would have been easier to follow...

You are having grief with data normalization.
There's a good tutorial here

Essentially, there should be no duplicates in Table1
Do yourself a favor and rename ID to ProjectID on all the tables
Now, in Tables 2-6 add a column.
Call them ProjectDataID, OpsID, LaborID, VehicleID, and PhonesID
Fill these columns with sequential numbers.

Now, you should be able to relate each table on ProjectID.

If you are not seeing what you want in your queries, you'll have to look at your data.
But, in a nutshell, if the data is good, you should be somewhat normalized

Now, if you were going to fully normalize it, you'd need more tables (vehicles, employees, cellphones ect) but you'll be started
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Each table should have its own primary key.  It may store a foreign key as many times as needed.  In your case, it appears that you have a primary key in table Projects named ID.  It should be named ProjID.  If in fact that same ID exists in all the other tables, the field name should be changed to ProjID, and your reference to that field in any of the other tables should be as a foreign key - ProjID

Now in the table ProjData it should have a pk - ProjDataID, as well as the foreign key ProjID, and so on down the line.

There is a reasonable amount of help in A2003 - type in - database design - for a start.
PhxDBAuthor Commented:
Thanks Guys.  Lots of good information!  Will have to do some studying and maybe re-thinking.

For the record, I did have "ProjID" for that field in each table.  I have now added Primary Keys to each table and numbered them sequentially.  Re-ran the queries and still ended up with the exact same records.

Instead of the screenprint on the original post ... this is basically what we want the query to show.

Desired Format
Of course it could be aligned differently, but the bottom line is that within each Project/Priority combination, there should be only 1 Bill Smith, 1 Veh# 423-921 etc.

Beginning to think that als315 was exactly correct ... but gonna try to find a way.  Any thoughts?  Thanks again.
Without seeing the data, there isn't much I can offer.
I have pointed you at data normalization tutorials.
Ultimately, if your queries aren't returning the data the way you want them, it's becuase your data isn't structured right.
If Bill Smith can appear with different priorities, then Bill Smith doesn't have a relationship with ProjectID, he has a Relationship with Project Data, perhaps.

Working your data down until it is fully normalized.
Its worth the effort.
This may be the structure that results
Project <---> ProjData on ProjID
                     ProjData <------>Labor on ProjDataID
The employee has an indirect relationship with the project, through project data.

Work your data down until it is fully normalized.  It's a fundamental skill and requirement
PhxDBAuthor Commented:
Thanks Nick - Like I said you have given me lots to work with here.  Will definitely look further into normalization.
PhxDBAuthor Commented:
While my problem has not been solved, these guys gave me alot of good information to help me try to find a solution.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now