Solved

Troubleshooting referential integrity

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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 …
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

778 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