Results 1 to 4 of 4
  1. #1
    smatchymo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2019
    Posts
    15

    Importing existing tables and trying to create referential integrity


    I'm brand new to access and I've taken a part 1 and part 2 course for work over the past several days. For practice, I wanted to play with some personal budget data I had. I have two tables, one for my categories and one for my transactions. The categories table lists the various locations I've spent money and the fields on the corresponding row list the category and subcategory for purchases at those locations. There are no duplicates of the purchase locations, so that is a primary key. My transaction table has, date of transaction, description, amount, account type, account institution, and purchase location.

    I have a relationship set between the purchase location columns of the two tables, but I'm unable to enforce referential integrity. I get an error stating access can't create the relationship and enforce referential integrity. Again, in the categories table, purchase locations have no duplicates. Those are being indexed with no duplicates. I have exported both tables to excel and I've done a lookup to ensure that every purchase location referenced in the transactions table is valid and pulls up a value from the categories table. What else should I be checking for exactly? Both purchase location fields are set to text with a 255 character limit. Any help would be greatly appreciated. Thanks in advance!

    Edit: I had run the "find unmatched query wizard" incorrectly. There were some entries in the transaction table that had a space at the beginning...

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    always better to use autonumber primary keys with related long as foreign key. The problem with text (as you have found) is spelling.

    from your description, you should have more that two tables - you also need two for your accounts (institution as master, type as child) and only need to store the key to the type in your transaction table since you can look up the institution when required.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I'm with Ajax. Every table I create has an Autonumber field as the PK field.

    AutoNumber
    ----------------
    Purpose: Use an AutoNumber field to provide a unique value that serves no other purpose than to make each record unique. The most common use for an AutoNumber field is as a primary key.


    More reading:
    Autonumbers--What they are NOT and What They Are
    Microsoft Access Tables: Primary Key Tips and Techniques

  4. #4
    smatchymo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2019
    Posts
    15
    Quote Originally Posted by Ajax View Post
    always better to use autonumber primary keys with related long as foreign key. The problem with text (as you have found) is spelling.

    from your description, you should have more that two tables - you also need two for your accounts (institution as master, type as child) and only need to store the key to the type in your transaction table since you can look up the institution when required.
    But by doing that, then wouldn't I be left with corrupted data? I would have had two similar entries that I wouldn't have known about. Now I know my locations are unique which was my primary goal. As for the institution/account relationship, the same institution can have multiple accounts, ie checking, savings, and credit.

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

Similar Threads

  1. Referential integrity problem with related tables
    By dgmdvm in forum Database Design
    Replies: 10
    Last Post: 12-12-2017, 06:49 PM
  2. Referential Integrity
    By lefty2cox in forum Forms
    Replies: 2
    Last Post: 11-30-2015, 07:26 AM
  3. Referential Integrity On Linked Tables
    By ribena1980 in forum Import/Export Data
    Replies: 4
    Last Post: 08-25-2015, 11:56 AM
  4. Referential Integrity
    By Paul H in forum Database Design
    Replies: 3
    Last Post: 11-14-2011, 03:07 PM
  5. referential integrity
    By askjacq in forum Database Design
    Replies: 1
    Last Post: 10-14-2011, 03:23 PM

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