Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

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].
 
Share this answer
 
Comments
Sanjay K. Gupta 7-Feb-12 1:22am    
Agreed! Sachin.
Thanks for giving your solution.
Take 5! from me.
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900