Results 1 to 6 of 6
  1. #1
    jduran2 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    4

    Relationships and Building new Tables

    I have been working with a software that delivers data using ".mdb" files or Access as seen below. These are large files with several primary keys that build relationships between the tables. I am not very familiar with Access, but these seem to be how the data is built together.



    My current goal is to filter the data in order to have a single table with adjusted columns from different tables. I have played around with the queries and been able to filter out information from individual columns, but is there a way to take columns and place them into a new table?

    For Example: Looking at my image, the first primary is analysis set where a primary key "AnalysisIndex" is located. This is a value that I am interested in having on my new table. However, Analysis set has a large set of "sub data". When I add this column to the new table, I want it to update its size so that it is not just 1,2,3,4,5,6,etc. but rather 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,etc. with the sub data in neighboring columns.

    Thanks

    Click image for larger version. 

Name:	relationships_image.png 
Views:	15 
Size:	65.1 KB 
ID:	26503

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    My current goal is to filter the data in order to have a single table with adjusted columns from different tables
    sounds like you are wanting an excel/spreadsheet view of the data which is not how databases are intended to work. They work using queries, just selecting whatever data is required for the purpose in hand

    For Example: Looking at my image, the first primary is analysis set where a primary key "AnalysisIndex" is located. This is a value that I am interested in having on my new table. However, Analysis set has a large set of "sub data". When I add this column to the new table, I want it to update its size so that it is not just 1,2,3,4,5,6,etc. but rather 1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,etc. with the sub data in neighboring columns.
    which means what? Perhaps provide some example data from all of the relevant tables and the expected outcome. Don't try to simplify it, just explain what it is you are trying to do, with examples

  3. #3
    jduran2 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    4
    Okay, I will give an specific example that I would like to repeat across all data.

    My first relevant data sets come from the AnalysisSet table. Let's say that we are interested in Analysis Index 100.

    Click image for larger version. 

Name:	Analysis_Set.png 
Views:	11 
Size:	32.8 KB 
ID:	26505

    I would next go to the AnalyteSet Table and find the corresponding Analysis Index of 100 which then has related fields of Analyte Index and Analyte Name that I am interested in keeping as well.

    Click image for larger version. 

Name:	Analyte_Set.png 
Views:	11 
Size:	36.7 KB 
ID:	26506

    This is where all of my "filtering" will take place. I have played around with this and managed to get it to work through using the Queries like you mentioned. I specifically used the criteria for Analyte Name and listed the strings that I am interested in. However, the other data that I will get to in a moment is not present when simply filtering through one column which is why I would like all of the associated columns to be side by side so that all columns are adjusted for the desired criteria.

    Next from the obtained Analyte Set, I need to open the Sample Set table and again find the appropriate Analysis Index value (100 in this example). Note in the image below that the Sample Index numbers share the Analysis Index number 100 for Sample Index (1658-1708)

    Click image for larger version. 

Name:	Sample_Set.png 
Views:	11 
Size:	52.9 KB 
ID:	26507

    Now, with these values, I can go to the Analyte Data table and gather all data for matching sample index numbers (1658-1708). This table also has the Analyte Index values for each Sample Index along with the values that I will ultimately be interested in (Mean Response and RSD).

    Click image for larger version. 

Name:	Analyte_Data.png 
Views:	11 
Size:	42.4 KB 
ID:	26508

    Now That I have the location of all data, I would like to sort of combine so that the new table or query has specific fields from each table.
    Fields:
    AnalysisIndex
    AnalyteIndex (For each AnalysisIndex)
    AnalyteName (For each AnalysisIndex)
    SampleIndex (For each AnalysisIndex)
    Label (For each AnalysisIndex)
    MeanResponse (for each AnalyteIndex and each SampleIndex)
    RSD (for each AnalyteIndex and each SampleIndex)

    Then, I with this setup and hierarchical organization, I would setup a criteria to filter on.

    This is at least the goal and vision that I have for the final output.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    OK, so what is the problem with using a query based on just the tables you have mentioned?

    You've explained your data which is helpful, thank you.

    1. join AnalysisSet to AnalyteSet on Analysisindex as indicated in your relationships
    2. join AnalysisSet to Sampleset on Analysisindex as indicated in your relationships
    3. join Sampleset to AnalyteData on SampleIndex as indicated in your relationships
    4. if relevant, you can also create a join between AnalyteData and AnalyteSet on AnalyteIndex

    Then in the query grid, drag down the fields you want to appear and/or apply a criteria

    Don't confuse relationships with joins, they may be represented the same way (like a table or query looks the same). Query joins are not restricted to what has been mapped as relationships

    Edit: (number added to joins for ease of identification)
    One other thought is you don't necessarily joins 2 and 3 since you don't appear to need any data from the Sampleset table, just joins 1 and 4

  5. #5
    jduran2 is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    4
    There is no issue using the query as you suggest. I was having issues because I was missing join 4. My solution was as you suggested; however, what are the differences in the different types of joins? I went with option 1 when creating the relationship and it simply made a direct connection as seen in the first image below. My final query ( as seen in the second image) appears to be correct, but I will dig through the data a bit more to confirm.

    image 1

    Click image for larger version. 

Name:	Query_Draft.png 
Views:	7 
Size:	37.4 KB 
ID:	26525

    image 2

    Click image for larger version. 

Name:	Final_Query.png 
Views:	7 
Size:	82.0 KB 
ID:	26526

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    however, what are the differences in the different types of joins?
    As I said before, don't confuse joins with relationships - per your query these are all 'normal' inner joins. The 1 and infinity signs just means there is a one to many relationship involved but does not affect the join. If you had outer joins (i.e. include all records from tableX and those records from tableY where there is equality) then you would see a arrow head at one end of the join line

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Building relationships
    By Tlattimer in forum Database Design
    Replies: 1
    Last Post: 07-15-2013, 11:12 AM
  2. Help with tables and relationships
    By DCarrollUSMC in forum Access
    Replies: 2
    Last Post: 10-15-2012, 02:33 PM
  3. Building Input Form Based on Two Tables
    By tx_developer in forum Forms
    Replies: 4
    Last Post: 07-28-2012, 01:51 PM
  4. Replies: 9
    Last Post: 05-29-2012, 04:45 PM
  5. Many to Many Relationships among 8 tables
    By Pilotwings_64 in forum Database Design
    Replies: 9
    Last Post: 10-30-2010, 03:12 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums