I'm having trouble wrapping my head around the proper way to do this.
I have three tables.
One is a list of wells with some header data.
The second table is a list of chemicals used to treat the well.
The third table relates to the second table, and provides descriptions of each chemcal.
A single well often has multiple chemicals used.
So table 1 lists each well once. It has a primary key (PKey) for each well. (approx 100k records)
Table 2 has a PKey1 field which links to the primary key field in Table 1. There is a separate entry for each chemical used, which means there are duplicate PKey1 entries (one duplicate for each chemical). Each entry then has it's own primary key (PKey). (Approx 1 million records)
Table 3 links to Table 2. It has a field called PKey2 that links to the primary key in table 2. It is a list of descriptions for each chemical by the company who used worked the well (Approx 2 million records)
I can easily link the tables and filter by county to get a manageable table size. For example, in the county of interest there are only 604 wells. If I link the tables by their proper primary keys and run the query I end up with approx 22k entries. So, basically those 604 wells multiplied by the number of chemicals used across all of them.
I have been asked to provide something that is more along the lines of:
Well, Name, etc (Header Info from Table 1)
- Chemical 1 info (derived from Table2 and Table3)
- Chemical 2 info
- Chemical 3 info
Well2
- Chemical 1 info
- Chemical 2 info
- Chemical 3 info
Well3
- Chemical 1 info
- Chemical 2 info
- Chemical 3 info
- Chemical 4 info
I'm at a bit of a loss as to how to provide the data in that format. I have a feeling it's easier than I am making it out to be in my head.