Solved

Troubleshooting referential integrity

Posted on 2008-06-17
3
196 Views
Last Modified: 2013-11-28
Table A                                      Table B
pkFieldOne     Text     1>>>M    fkFieldOne     Text
pkFieldTwo    Test      1>>>M   fkFiledTwo     Text
9000 records              7000 records

Not all records need to reside in Table B   just all 7000 records need to relate to Table A
Access 2000/2003   recognizes the 1 to many relatiionship but it won't allow the setting of RI

I have ran two unmatching fields  One where pkFieldOne = fkFieldOne  and the other where pkFieldTwo = fkFieldTwo  fix the problems then tried to set RI and it still will not set.  I think I have unmatching groupings of fieldOnes and fieldTwos

I found this problem by the ability of adding data into TableB without any error messages.   This messes things up.  
How do I run one unmatching field query where it pkFieldOne = fkFieldOne  AND pkFieldTwo = fkFieldTwo?
0
Comment
Question by:MG_Janiszewski
3 Comments
 
LVL 51

Accepted Solution

by:
Mark Wills earned 500 total points
ID: 21808732
OK, as a query, go into SQL view and paste the following

Select b.fieldone,b.fieldtwo from tableb b
left outer join tablea a on b.fieldone = a.fieldone and b.fieldtwo = a.fieldtwo
where a.fieldone is NULL;


basically what we are saying is from tableb join to tablea but (using left outer) we do not care if tablea has matching records. The "where" will select those rows where there is no tablea row that matches (because it will be NULL)
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21816200
MG_Janiszewski,

Just curious,

Why do you have two primary keys in the same table linked to two of the same foreign keys in a second table?

JeffCoachman
0
 

Author Comment

by:MG_Janiszewski
ID: 21818132
The whole database is centered around fieldOne and FieldTwo.  TableA is the Master table and Table B breaks additional information about the data in Table A.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now