Trouble with a pseudo unmatched query

ths

Registered User.
Local time
Today, 00:15
Joined
Apr 11, 2012
Messages
10
Hi,

I have a table with two fields, articleID and relatedArticleID. They are both primary keys to prevent duplicate combinations of the pair. This is linked, one-to-many, to the articles table.

I want to find where a relationship only exists in one direction but not the other. For example, in the following table, article 1 has three related articles, but only two of the articles reference article 1 as a related article. I want to find row #2 so that I can determine whether or not to create the reverse.

row# articleID relatedArticleID
1 1 2
2 1 3
3 1 4
4 2 1
5 4 1

Any advice on how to go about this? I feel like the solution is likely simple, but I've been banging my head against the wall...

Many thanks.

Tim
 
Thanks, Pat. Appreciate the response, the clarification on the compound key, and the tips.

I made the two unmatched queries and unioned them, but I think I might not have explained the situation clearly.

There's no issue with the data needing to be cleaned up--from my perspective at least. I am enforcing RI between the articles table (ID) and the relatedArticles table (articleID), which I am using to capture user-picked associations between a given article and other articles in the articles table.

For example, if these were articles on music, a user might want to assign articles on Requiem Masses, the Piano, etc, as related to the Brahms article. But the user might not want to assign the Brahms article as related to the Piano article--or they might. I want to give the users visibility on which associations are not captured in both directions, in case they want to create that association--or confirm that they do not.

Sorry if you got all that on the first round and I misunderstood the solution... Thanks again.

Tim
 

Users who are viewing this thread

Back
Top Bottom