Click here to Skip to main content
14,301,265 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have two tables and in one table I have created primary key of three combined columns like "ID, ClientID, PanelID" and in other table have a same column as "ID"
So, I want to make relations of both table on column ID. But it was not relating.

Is both table should required composite columns ?
Posted
Comments
Amir Mahfoozi 7-Feb-12 1:39am
   
Your question is not clear. Give an example.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Yup, Other table must have three columns, and it makes sense as your "ID" column can have duplicate values and this will create ambiguity.
better to use an Identity column, you can give unique key constraint to multiple columns[without making them as primary key].
   
Comments
Sanjay K. Gupta 7-Feb-12 1:22am
   
Agreed! Sachin.
Thanks for giving your solution.
Take 5! from me.
Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi,


The rule for relation key(Foreign key) between two table is, Both column should have same DataType and Size. if in one table it's composite primary key, it should be the same on another table.


thanks
-Amit.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100