Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


1-Many Relationship X 5

Posted on 2011-09-07
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 40

Assisted Solution

als315 earned 400 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 1200 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

LVL 44

Assisted Solution

GRayL earned 400 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.

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 1200 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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

604 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