Solved

Troubleshooting referential integrity

Posted on 2008-06-17
3
198 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

856 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