Solved

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

Posted on 2008-06-12
2
203 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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