Results 1 to 4 of 4
  1. #1
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91

    Importing data from two tables as an ID reference

    I am trying to build a normalized database from a few Excel data sources, and one general problem I run into is translating direct text relationships into a relationship between a primary table and a reference table, referencing the ID from the primary table.



    For example, I have a tblComponents ([ID], [Component], [Description], [kCategory1], [kCategory2] ,[kCategory3]) containing all of my components. Each of these can have up to three levels of categorization, which in this table is represented by three Number fields. These number fields should point to the PK of a reference table, which contains all of the categories and their levels ([ID], [Category], [categoryLevel]).

    I have imported a table with four columns: component (text) and three category columns (text).

    I want to match up the first category name with the reference table's text column, then bring the corresponding number into the tblComponents table. is there any clean way to do this easily? This is a problem I've run into in a bunch of different contexts when translating csv's to databases.


    Click image for larger version. 

Name:	DB_categories.png 
Views:	15 
Size:	24.7 KB 
ID:	47814

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    What you have is not normalized; you need a join table with three fields: ComponentCategoryID (autonumber, PK), ComponentID_FK (Number, Long - foreign key link to tblComponent),CategoryID_FK (Number,Long, foreign key link to tblCategory).

    Same thing for tblProcurementMast you shouldn't have fields that act as data (2021Quantity and 2021Spend) - you need another table with a proper structure: ProcValuesID (PK, autonumber), ProcurementID_FK(number, long), Quantity, Spend, ProcurementYear.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91
    Quote Originally Posted by Gicu View Post
    What you have is not normalized; you need a join table with three fields: ComponentCategoryID (autonumber, PK), ComponentID_FK (Number, Long - foreign key link to tblComponent),CategoryID_FK (Number,Long, foreign key link to tblCategory).

    Same thing for tblProcurementMast you shouldn't have fields that act as data (2021Quantity and 2021Spend) - you need another table with a proper structure: ProcValuesID (PK, autonumber), ProcurementID_FK(number, long), Quantity, Spend, ProcurementYear.

    Cheers,
    tblProcurementMast is just an imported spreadsheet from which I am pulling data to populate the database. My goal was to establish these as temporary relationships simply for the importing process, after which tblComponents would have a numerical FK for each category field pointing to a PK number in the categories reference table. The tblProcurementMAST table would be removed from database once importing is complete

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Same thing applies to this; create a proper table structure then run three append queries to move the data from the procurement table into a temp table with one category (each of the three appends pushes one of the three Kearney_L... fields into a Category field).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Importing data for Linked Tables
    By deepakg27 in forum Import/Export Data
    Replies: 6
    Last Post: 08-23-2018, 10:39 AM
  2. Importing Excel Data Tables into Access
    By Itch in forum Programming
    Replies: 5
    Last Post: 09-08-2012, 11:27 AM
  3. Replies: 4
    Last Post: 01-31-2012, 12:42 PM
  4. Importing data into various tables
    By simba in forum Import/Export Data
    Replies: 1
    Last Post: 01-13-2011, 12:42 PM
  5. Importing and mapping data to various tables
    By rasticle in forum Import/Export Data
    Replies: 1
    Last Post: 05-17-2010, 04:22 PM

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