Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Using One Composite Foreign Key Value As Foreign Key In Another Table Expand / Collapse
Author
Message
Posted Thursday, October 10, 2013 9:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 10, 2013 9:55 AM
Points: 8, Visits: 10


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.
Post #1503684
Posted Thursday, October 10, 2013 7:02 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 4:14 AM
Points: 3,618, Visits: 5,254
Why don't you post the DDL you have created so far?


My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
Post #1503843
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse