1-Many Relationship X 5

Posted on 2011-09-07
Last Modified: 2012-05-12
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.    
Question by:PhxDB
LVL 39

Assisted Solution

als315 earned 100 total points
ID: 36497720
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.
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36497732
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...

LVL 26

Assisted Solution

Nick67 earned 300 total points
ID: 36497917
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
LVL 44

Assisted Solution

GRayL earned 100 total points
ID: 36497938
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.
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.


Author Comment

ID: 36505510
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.
LVL 26

Accepted Solution

Nick67 earned 300 total points
ID: 36505708
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

Author Comment

ID: 36506076
Thanks Nick - Like I said you have given me lots to work with here.  Will definitely look further into normalization.

Author Closing Comment

ID: 36506096
While my problem has not been solved, these guys gave me alot of good information to help me try to find a solution.

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now