Results 1 to 6 of 6
  1. #1
    jeng is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    3

    Relating 2 Tables - Relational Problem

    Hi,

    Im having a problem with designing a database realationship between 2 tables.

    I have 2 tables; 'Composition' and 'Tx Test results'.

    'Tx Test results' has "Transformer ID" as a primary key, and 'Composition' has a composite key of "Transformer ID" and "Date Tested".



    In Access, how do i relate the composite key (I.e. the combination of Both Transformer ID and Date Tested) to the Transformer ID in the 'Tx Test Results table'

    Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why are you using a composit key for the Composition table? Are there many entries in that table with the TransformerID in a field?

  3. #3
    jeng is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    3
    Yeh thats right RuralGuy,


    It contains entries of the same transformers in there, tested on different dates.

    So, Transformer 1 can be tested on 4 different days in the space of a year. While Transformer 2 may have only been tested once.

    Therefore, it is the combination of Transformer ID AND Date which uniquley identifies a record.

    ....Any ideas on how to relate the two tables?

    Thanks very much!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The two tables sound like they have a 1:M relationship with each other and you would use the TransformerID field to define the relationship. You would display this relationship with a MainForm/SubForm arrangement with the MANY side on the SubForm in Continuous Form view. No date involved in defining the relationship.

  5. #5
    jeng is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    3
    Thanks for the reply RuralGuy,

    Are you saying, in order for me to establish the relationship between the two tables, that i would have to:

    Click on the relationships menu from the toolbar in Access > Drag the PK (Transformers) from the Composition table, to the PK (Transformers) in the 'Transformer Test Results' table?

    When i do this i am given an error that goes along the lines of "You have duplicates in the PK field"

    This is because the Composite Key is comprised of Transfomer AND Date.

    How do i relate the composite key of Transformer AND Date (in the compositions table), to Transformer in the (Transformer ID Table)?

    Cheers.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would *not* use a composit key. I would let each table have an AutoNumber as a PrimaryKey and the ManySide table would have a ForeignKey field named TransformerID with the appropriate LongInteger value from the other table in it. You do not need nor should you use a date to relate these two tables.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-31-2010, 01:56 PM
  2. Replies: 0
    Last Post: 03-03-2010, 01:28 PM
  3. Query problem with multiple tables
    By DanW in forum Queries
    Replies: 1
    Last Post: 11-20-2009, 06:23 PM
  4. Tables and “all data query” ID problem
    By mashe in forum Queries
    Replies: 5
    Last Post: 08-22-2009, 06:05 AM
  5. Replies: 0
    Last Post: 01-08-2009, 05:49 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