Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
azinyama
Starting Member
7 Posts |
Posted - 2013-10-10 : 11:49:30
|
Good day all!!! I have the tables, as in image above, and I'm trying to create the relationships. I got stuck at creating a relationship between tables 'member_provider' and 'dependant_provider'.As you can see, member_provider has a composite primary key that is made up of to foreign keys 'Member_RowID' and 'Provider_RowID'. I want to maintain this composite primary key and then create a relationship with dependant_provider using Member_Provider_RowID. I have tried adding Member_Provider_RowID to the composite key in member_provider but when I try to create the relationship I get the following error:"The columns in table 'member_provider' do not match an existing primary key or UNIQUE constraint"How would I go about maintaining the the uniqueness of the tables two columns.I'm using MSSql Server 2008...Thanx in advance. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-10-10 : 12:36:34
|
You would have to create a unique index on the Member_Provider_RowID in the member_provider table. If you did not have that, then there could be more than one row in that table with the same value of Member_Provider_RowID. When that happens, SQL Server wouldn't know which of those rows the foreign key is referring to. Hence this restriction. |
|
|
azinyama
Starting Member
7 Posts |
Posted - 2013-10-10 : 14:03:49
|
Thanx a lot for the speedy response James... That did the trick... |
|
|
|
|
|