Solved

Cannot create a relationship between two specific tables in a database as error message occurs

Posted on 2008-06-12
2
206 Views
Last Modified: 2011-10-19
Cannot create a relationship between two specific tables in a database as error message occurs.

I need to create a cascading relationship between two tables, users and addressDetails.

However, an error occurs (file is attached) and wont let me create the relationship, even if i remove the cascading delete.
Any clues?
All other tables with similar links do work.

Thanks Julia
MembershipSchema.txt
0
Comment
Question by:Juliafrazer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 100 total points
ID: 21768581
The only way you're going to be able to create your unique constraint is for you to remove the duplicates from the table for the column you're trying to create the constraint on.
0
 
LVL 1

Accepted Solution

by:
Bernard_Jakopovic earned 400 total points
ID: 21768670
combination of PK columns in addressDetails produces duplicate key. try to build PK on addressDetails separately, finding out what rows are producing this error. You can do that with query like:

select PKcolumn1, PKcolumn2.. from addressDetails group by  PKcolumn1, PKcolumn2 having count(*)>1

this will list all duplicate keys.
(PKcolumn1, PKcolumn2.. are all columns you use for PK in addressDetails table)
you will probably have to extend PK to more columns, or remove duplicate data.

This, however, doesnt affect building the relationship exept if Users is FK table (you are puting relation on addressDetails in users table) and this is a wrong approach in modeling. You must put FK to users in addressDetails. So, you evidently have two problems to solve :)
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

634 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