Solved

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

Posted on 2008-06-12
2
198 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
2 Comments
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 100 total points
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now